我试图从我的MVC应用程序发送电子邮件,但是当我尝试发送它时,我收到此错误消息" 无法找到路径的一部分' C:\ TEMP \ 67088830-4abc-41c6-afbe-6856bb817889.eml' "在这一行
smtp.Send(mail);
关于如何解决此错误的任何想法或建议......
这也是我发送它的代码。
MailMessage mail = new MailMessage();
mail.To.Add(ConfigurationManager.AppSettings["To"]);
mail.From = new MailAddress(ConfigurationManager.AppSettings["From"]);
mail.Subject = ConfigurationManager.AppSettings["Subject"];
string Body = "Test";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = ConfigurationManager.AppSettings["Host"];
smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential
(ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Pass"]);
smtp.EnableSsl = false;
smtp.Send(mail);
答案 0 :(得分:3)
尝试在webconfig或文件中设置smtp传送方法到网络
<smtp deliveryMethod="Network">