开发者

get the error message from SendCompletedEventHandler using SmtpClient

get the error message from SendCompletedEventHandler using SmtpC开发者_Python百科lient


I'm guessing this is what you wanted..

Main()
{
    SmtpClient MyClient = new SmtpClient(args[0]);

    // define to, from and message body

    MyClient.SendCompleted += new 

    SendCompletedEventHandler(SendCompletedCallback);

    client.SendAsync(message, userState);
    message.Dispose();


}
private static void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
     static bool MailStatus= false;

     if (e.Error != null)
     {
          Console.WriteLine("{1}", e.Error.ToString());
     }
     else
     {
         Console.WriteLine("Message sent.");
     }

     MailStatus = true;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜