【发布时间】:2013-01-02 04:06:33
【问题描述】:
使用 Visual Studio 从我的 ASP.NET 项目发送电子邮件非常快——只需一秒钟——但在同一台机器上的 IIS 7 中发布时,需要 50 秒或更长时间。有没有人遇到过这种速度降低?我已将 C# 代码和我的设置粘贴到 web.config 中。非常感谢。
public static bool EnviarMail(String eOrigen, String eDestino, String asunto, String cueMensaje)
{
Boolean EstadoEnvio;
MailMessage eMail = new MailMessage();
eMail.From = new MailAddress(eOrigen);
eMail.To.Add(new MailAddress(eDestino));
eMail.Subject = asunto;
eMail.IsBodyHtml = true;
cueMensaje = cueMensaje.Replace("\r\n", "<BR>");
eMail.Body = cueMensaje;
eMail.Priority = MailPriority.Normal;
SmtpClient clienteSMTP = new SmtpClient();
try
{
clienteSMTP.Send(eMail);
EstadoEnvio = true;
}
catch
{
EstadoEnvio = false;
}
return EstadoEnvio;
}
在我的 web.config 中:
<mailSettings>
<smtp from="iso@hmoore.com.ar">
<network host="174.120.190.6" port="25" userName="iso@hmoore.com.ar" password="-----" defaultCredentials="true"/>
</smtp>
</mailSettings>
【问题讨论】:
-
如果将
defaultCredentials设置为false会发生什么? -
您是否尝试过在 IIS 中使用与您的 Visual Studio 实例相同的用户运行应用程序池?
-
你是如何测量你的 50 秒的?
-
@ken2k 你好,我使用的是完全相同的用户,我也是计算机管理员。谢谢
-
嗨@mathieu,我在调用该方法之前捕获了时间,然后在您运行该方法时再次捕获。
标签: c# asp.net performance email iis