熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP.NET 發郵件

2022-06-13   來源: .NET編程 

  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
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.