【发布时间】:2015-02-17 11:55:20
【问题描述】:
下面的代码使用 System.Net.Mail.MailMessage/System.Net.Mail.SmtpClient 从运行在 Windows 2008R2 上的 IIS7 上的 ASP.NET/C# 3.5SP1 应用程序中通过电子邮件发送文件。尽管我们已经 3 年多没有更改代码,但它最近开始发送重复的电子邮件。例如,如果 me@me.com 是 currentVendor.Email,则 me@me.com 会收到两封完全相同的单独电子邮件。有任何想法吗? Windows 更新会导致这种情况吗?
Vendor currentVendor = Vendor.GetCurrent();
string POLocation = Vendor.GetPOLocation();
#if !DEBUG
MailMessage mailer = new MailMessage("orders@perks.com", "resdev@perks.com");
string[] addresses = currentVendor.Email.Split(new char[] { ';', ',' });
foreach (string recip in addresses)
{
mailer.To.Add(recip.Trim());
}
#else
MailMessage mailer = new MailMessage("orderstest@me.com", "devtest@me.com");
#endif
mailer.Subject = String.Format("{0} V2 Purchase Orders - {1}", currentVendor.Name, DateTime.Today.ToShortDateString());
mailer.IsBodyHtml = true;
mailer.Body = "Please find attached..... <br/>" +
"This email is system generated. If you have any trouble please, contact us";
mailer.Attachments.Add(new Attachment(POLocation));
SmtpClient mailClient = new SmtpClient();
mailClient.Send(mailer);
提前致谢!
【问题讨论】:
标签: c# .net email system.net.mail mailmessage