程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> Subtext(8) -- DotNetOpenMail

Subtext(8) -- DotNetOpenMail

編輯:.NET實例教程

DotNetOpenMail 在 Subtext 中應用。

DotNetOpenMail 是一款發送郵件的控件。感覺使用起來,用法較簡單,大家都已經會使用了。在這裡做為Subtext系列的一部分簡單重新提下,望大家共同探討 :)

從Subtext可以分析出來,它提供了2種 provider,一個是SystemMailProvider,另一個是DotNetOpenMailProvider 。前者是大家所熟悉的使用System.Web.Mail命名空間;後者是我們討論的重點。

DotNetOpenMail使用范例:

1. 在工程中引用DotNetOpenMail.dll (下載地址:http://sourceforge.Net/project/showfiles.PHP?group_id=129974&package_id=143561)

2. 使用代碼,例如:

 



private void Button1_Click(object sender, System.EventArgs e)
...{
    EmailMessage email = new EmailMessage();
    email.FromAddress = new EmailAddress([email protected]);

//發件人郵箱
    email.AddToAddress(new EmailAddress([email protected]));

//收件人郵箱

email.AddBccAddress(new EmailAddress([email protected]));

//暗送人郵箱
email.AddCcAddress(new EmailAddress([email protected])); 

//抄送人郵箱


    email.Subject= "test";

//郵件主題
    email.BodyText = "test";

//郵件內容 

    SmtpServer smtp = new SmtpServer("smtp.163.com",25);
    smtp.SmtpAuthToken = new SmtpAuthToken("username","passWord");

//配置smtp服務器,設置用戶名和密碼
    try
&nb   ...{
        email.Send(smtp);
    }
    catch(MailException MailEx)
    ...{    
        Response.Write(MailEx);
    }
    catch(SmtpException SmtpEx)
    ...{
        Response.Write(SmtpEx);
    } 



 

更詳細的資料,可以參考:

DotNetOpenMail說明文檔

http://dotnetopenmail.sourceforge.Net/api/

DotNetOpenMail Api參考手冊

http://dotnetopenmail.sourceforge.Net/examples.Html

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved