像 C# 中的 replyto 一样为 MailMessage 配置 forward-to 属性
Configure forward-to property for MailMessage like replyto in C#
有什么方法可以配置转发电子邮件地址,例如 System.Net.Mail.MailMessage 中的回复?
如果没有,那我有什么办法可以实现吗?
您只能通过 Outlook 执行此操作(使用互操作)
var newItem = mailItem.Forward();
newItem.Recipients.Add("test@test.be");
newItem.Send();
.Forward()
描述here
没有,没有。
原因是邮件中没有定义这样的字段。可以看到定义的字段here.
所以这不是C#的问题API,没有办法做你想做的,C#不行,其他的不行languages/frameworks。
MailMessage 中没有 'forwardto'(这取决于接收邮件的用户)。
但是您可以使用 CC
或 BCC
属性一次发送给 multiple
个收件人。
这是一个使用 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() );
}
}
现在您可以发送给多个,就像自动转发一样。
有什么方法可以配置转发电子邮件地址,例如 System.Net.Mail.MailMessage 中的回复? 如果没有,那我有什么办法可以实现吗?
您只能通过 Outlook 执行此操作(使用互操作)
var newItem = mailItem.Forward();
newItem.Recipients.Add("test@test.be");
newItem.Send();
.Forward()
描述here
没有,没有。
原因是邮件中没有定义这样的字段。可以看到定义的字段here.
所以这不是C#的问题API,没有办法做你想做的,C#不行,其他的不行languages/frameworks。
MailMessage 中没有 'forwardto'(这取决于接收邮件的用户)。
但是您可以使用 CC
或 BCC
属性一次发送给 multiple
个收件人。
这是一个使用 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() );
}
}
现在您可以发送给多个,就像自动转发一样。