中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

異步發(fā)送郵件C#代碼

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用

下面的代碼可以實現異步發(fā)送郵件,等郵件發(fā)送出去后會自動調用回調函數,這樣在發(fā)送郵件時就不會卡住程序不動了

MailMessage m = new MailMessage
   ("item@sharejs.com",
    "raja@sharejs.com",
    "This is the subject for the authorized email.",
    "This is the body of the authorized mail!...");
  
// Send the message using authorization
SmtpClient client = new SmtpClient("smtp.sharejs.com");
client.Credentials = new NetworkCredential("user", "password");
client.EnableSsl = true;
  
// Add the event handler
client.SendCompleted += new SendCompletedEventHandler(mail_SendCompleted);
  
// Send the message asynchronously
client.SendAsync(m, null);
  
// To Cancel the send
//client.SendAsyncCancel();
void mail_SendCompleted(object sender, AsyncCompletedEventArgs e)
{
    if (e.Cancelled)
        Console.WriteLine("Message cancelled");
    else if (e.Error != null)
        Console.WriteLine("Error: " + e.Error.ToString());
    else
        Console.WriteLine("Message sent");
}

標簽: ssl 代碼

版權申明:本站文章部分自網絡,如有侵權,請聯系:west999com@outlook.com
特別注意:本站所有轉載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權歸原作者所有,如需使用,請與原作者聯系。

上一篇:Android 應用程序的快捷方式

下一篇:PHP刪除指定目錄中的所有目錄及文件(或者指定文件)