using Systemusing SystemCollectionsGenericusing SystemLinqusing SystemWebusing SystemWebUIusing SystemWebUIWebControlsusing SystemNetMailusing SystemNetpublic partial class _Default SystemWebUIPage { protected void Page_Load(object sender EventArgs e)
{ } protected void Button_Click(object sender EventArgs e)
{
MailMessage msg = new MailMessage()msgBody = thisTextBoxTextmsgFrom = new MailAddress()msgSubject = thisTextBoxTextmsgToAdd()
//SmtpClient sc = new SmtpClient( )//SmtpClient sc = new SmtpClient()//scCredentials = new NetworkCredential(asdf)//scSend(msg)msgIsBodyHtml = true //郵件默認格式是純文本 //可發送超鏈接 如<a >百度</a> SmtpClient sc = new SmtpClient()scHost = scPort = NetworkCredential nc = new NetworkCredential()ncUserName = youxiangmingncPassword = mimascCredentials = ncstring filename = thisFileUploadFileNamethisFileUploadSaveAs(ServerMapPath(~/) + filename)Attachment att = new Attachment(ServerMapPath(~/) + filename)msgAttachmentsAdd(att)scSend(msg)} protected void Button_Click(object sender EventArgs e)
{ jmailMessage msg = new jmailMessageClass()msgSubject = thisTextBoxTextmsgBody = thisTextBoxTextmsgFrom = msgAddRecipient()msgMailServerUserName = youxiangmingmsgMailServerPassWord = mimamsgCharset = utf //顯示漢字msgContentType = text/htmlmsgSend()}
From:http://tw.wingwit.com/Article/program/net/201311/11453.html