-2

Is there any way to configure forward-to email address like replyto in System.Net.Mail.MailMessage? If not then is there any way I can achieve that?

Akshay Naik
  • 669
  • 1
  • 6
  • 22
  • 1
    Does such a thing even exist? Why would the sender of a message set the default where I'd forward it to? I'm curious what the business case might be. – nvoigt Oct 12 '18 at 14:37
  • You can add more than one address to send to, that Works like forwarding. – Poul Bak Oct 12 '18 at 15:01
  • @nvoigt my customer wants user not to reply email to from email address, if forward to email address is configured user will not make any modification in address bar like reply-to, currently some users are forwarding mail by copy pasting from email address instead of replying – Akshay Naik Oct 15 '18 at 05:58
  • @PoulBak can you explain little bit more. – Akshay Naik Oct 15 '18 at 05:58

3 Answers3

0

You can do this only by doing it via Outlook (using interop)

 var newItem = mailItem.Forward();
 newItem.Recipients.Add("test@test.be");
 newItem.Send();

the .Forward() is described here

Kahn Kah
  • 1,389
  • 7
  • 24
  • 49
  • I want use case like when user will click on forward email address then configured email address should automatically come to TO email address field instead of blank field. – Akshay Naik Oct 15 '18 at 06:02
0

No, there is not.

The reason is that there is no such field defined in an email. You can see the defined fields here.

So this is not a matter of C# API, there is no way to do what you want to do, not in C# and not in other languages/frameworks.

Community
  • 1
  • 1
nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • If you had control of all your receivers email clients, you could force a specific one on them and have them install a plug-in. But with just sending an email to random people? No. – nvoigt Oct 15 '18 at 06:51
0

There's no 'forwardto' in MailMessage (that's up to the user receiving the mail).

But you can send to multiple receipients at once, using either the CC or the BCC properties.

Here's an axample using CC:

public static void CreateCopyMessage(string server)
{
    MailAddress from = new MailAddress("ben@contoso.com", "Ben Miller");
    MailAddress to = new MailAddress("jane@contoso.com", "Jane Clayton");
    MailMessage message = new MailMessage(from, to);
    // message.Subject = "Using the SmtpClient class.";
    message.Subject = "Using the SmtpClient class.";
    message.Body = @"Using this feature, you can send an email message from an application very easily.";
    // Add a carbon copy recipient.
    MailAddress copy = new MailAddress("Notification_List@contoso.com");
    message.CC.Add(copy);
    SmtpClient client = new SmtpClient(server);
    // Include credentials if the server requires them.
    client.Credentials = CredentialCache.DefaultNetworkCredentials;
    Console.WriteLine("Sending an email message to {0} by using the SMTP host {1}.",
         to.Address, client.Host);

   try {
      client.Send(message);
    }
    catch (Exception ex) {
      Console.WriteLine("Exception caught in CreateCopyMessage(): {0}", 
                  ex.ToString() );
      }
  }

Now you can send to more than one, which Works like auto forwarding.

Poul Bak
  • 10,450
  • 5
  • 32
  • 57