如果你的ASPNET程序學得不錯了想用ASPNET來發送郵件在網上有好多文章本站不管網上說是如何實現的下面整理兩種NET發送郵件的方法給你參考一下很簡單的哦
第一種
配置文件(nfig) + 少量C#代碼
在 configuration 節點下添加
<> <mailSettings> <smtp from=> <network host= password=baidu port= userName=baidu defaultCredentials=false/> </smtp> </mailSettings> </>
/// <summary>
/// 發送郵件/// </summary>private void SendMail(){ SystemNetMailMailMessage message = new SystemNetMailMailMessage(); messageFrom = new SystemNetMailMailAddress();//發送人郵箱地址與smtp節點中的from值一致 messageToAdd(new SystemNetMailMailAddress());//接收人郵箱地址 messageSubject = hello; messageBody = <b>taobao</b>; messageIsBodyHtml = true; SystemNetMailSmtpClient smtpclient = new SystemNetMailSmtpClient(); smtpclientSend(message);}
好介紹完第一種發送郵件的方法下面看第二種
/// <summary>
/// 發送郵件/// </summary>private void SendMail(){ SystemNetMailMailMessage message = new SystemNetMailMailMessage(); messageFrom = new SystemNetMailMailAddress();//發送人郵箱地址與smtp節點中的from值一致 messageToAdd(new SystemNetMailMailAddress());//接收人郵箱地址 messageSubject = hello; messageBody = <b>taobao</b>; messageIsBodyHtml = true; SystemNetMailSmtpClient smtpclient = new SystemNetMailSmtpClient( ); smtpclientCredentials = new SystemNetNetworkCredential(baidu baidu);//參數分別是郵箱用戶名和密碼 smtpclientSend(message);}
怎樣上面兩種發送郵件的方法都很簡單吧
From:http://tw.wingwit.com/Article/program/net/201311/11581.html