CDO

出自 ProgWiki
前往: 導覽搜尋

CDO(Collaboration Data Objects)是ASP常用的寄email的ActiveX元件,IIS 4.0或 Windows 2000 Server內建。參照:『維基百科~Collaboration_Data_Objects

CDO的各版本

  • CDO 1.2 for Windows NT Server (CDONTS.DLL)
IIS 4.0 (Windows NT 4.0 Option Pack 1) and Windows 2000 Server.
  • CDO for Windows 2000 (CDOSYS.DLL)
Windows 2000 Server only.
  • CDO for Exchange 2000 Server (CDOEX.DLL)
Exchange 2000 Server.

技術文件

使用範例

Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
 
Set objMail = Server.CreateObject("CDO.Message")
objMail.Subject = "email主旨"
objMail.Sender = "寄件者email"
objMail.From = "寄件者email"
objMail.To = "收件者email"
objMail.TextBody = "email內容"
 
'SMTP server 連線設定
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
 
'SMTP Server 的IP或名稱
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp主機"
 
'登入SMTP Server的認證模式 (0 = NONE, 1 = Basic (Base64 encoded), 2 = NTLM)
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
 
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "寄件者email"
 
'連線到 SMTP server 的密碼
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "寄件者密碼"
 
'Server port (預設 25)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
 
'是否使用SSL加密連線? (False or True)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
 
'更新連線設定
objMail.Configuration.Fields.Update
 
'寄件
objMail.Send

相關

  • JMail(由於CDO在使用時,限制一堆,所以大部份的人都會改用JMail)