为MailMessage配置转发属性,例如C#中的Replyto

时间:2018-10-12 14:14:05

标签: c# mailmessage

有什么方法可以配置转发电子邮件地址,例如System.Net.Mail.MailMessage中的Replyto? 如果没有,我有什么办法可以实现?

3 个答案:

答案 0 :(得分:0)

您只能通过Outlook(使用互操作)来做到这一点

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

here被描述为.Forward()

答案 1 :(得分:0)

不,没有。

原因是电子邮件中没有定义此类字段。您可以看到定义的字段here

所以这不是C#API的问题,没有办法做您想做的事,不是用C#,也不是其他语言/框架。

答案 2 :(得分:0)

MailMessage中没有“转发”(这取决于接收邮件的用户)。

但是您可以使用multipleCC属性,一次发送给BCC收件人。

以下是使用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() );
      }
  }

现在,您可以发送多个邮件,就像自动转发一样。