欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#實現(xiàn)QQ郵箱發(fā)送郵件

 更新時間:2019年01月23日 09:01:46   作者:chenqiangdage  
今天小編就為大家分享一篇關(guān)于C#實現(xiàn)QQ郵箱發(fā)送郵件,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧

計劃著改善公司的郵件服務(wù)。怎料公司網(wǎng)絡(luò)封閉的太厲害了。我只能在家里利用開放點的網(wǎng)絡(luò)來測試發(fā)送郵件;

利用qq郵箱發(fā)送到公司的企業(yè)郵箱上;

前提準(zhǔn)備,登陸qq郵箱開啟stmp服務(wù)。不開啟的話沒法通過代碼登陸到你的郵箱;

查詢騰訊qq郵箱的smtp主機地址為:smtp.qq.com  端口是587,或者465

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
namespace mail
{
  class Program
  {
    static void Main(string[] args)
    {
      //發(fā)件人地址
      MailAddress from = new MailAddress("*********@qq.com");
      MailMessage message = new MailMessage();
      message.Body = "this is a test";
      message.IsBodyHtml = true;
      message.BodyEncoding = System.Text.Encoding.UTF8;
      //收件人地址
      message.To.Add("********bizip.com");
      message.Subject = "hello !";
      message.SubjectEncoding = System.Text.Encoding.UTF8;
      message.From = from;
      SmtpClient client = new SmtpClient();
      client.EnableSsl = true;
      client.Host = "smtp.qq.com";
      client.Port = 587;
      //郵箱賬戶和密碼
      client.Credentials = new System.Net.NetworkCredential("mailacount","password");
      try
      {
        client.Send(message);
      }
      catch (Exception ex)
      {
        string mssage = ex.ToString();
      }     
    }
  }
}

很簡單啊

vs2010測試通過!

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接

相關(guān)文章

最新評論