smtpClient.SendAsync:电子邮件永远不会到达C#

时间:2017-06-18 03:43:42

标签: c# asynchronous .net-3.5 smtpclient sendasync

SmtpClient Client = new SmtpClient(SMTPClientHostName, 25)
{
      EnableSsl = true,
      Timeout = 30000,
      DeliveryMethod = SmtpDeliveryMethod.Network,
      UseDefaultCredentials = false,
      Credentials = new System.Net.NetworkCredential(SenderEmailAddress, SenderEmailAddressPassword)
};

Object Object = MailMessage;

Client.SendCompleted += new SendCompletedEventHandler(SMTPClient_SendCompleted);

Client.SendAsync(MailMessage, Object);

我试图通过SendAsync发送电子邮件。它永远不会到来。

活动:

private static void SMTPClient_SendCompleted(object Sender, System.ComponentModel.AsyncCompletedEventArgs AsyncCompletedEvent)
{
   MailMessage MailMessage = AsyncCompletedEvent.UserState as MailMessage;
}

自我发送以来已经十分分钟。 消息 以Send发送。

这里有什么问题?

更新:我的代码包含使用;删除后,电子邮件开始到达。有谁知道为什么

0 个答案:

没有答案