簡單的Sample Code
<% set Mail = Server.CreateObject("CDONTS.NewMail")
Mail.BodyFormat = 0
Mail.MailFormat = 0
Mail.From = "寄件者"
Mail.To = "收件者"
Mail.Subject = "主旨"
Mail.body ="內容"
Mail.Send
Set Mail=Nothing
%>
功能較多的Sample Code
<%Set email = Server.CreateObject("CDO.Message")
email.From ="寄件者"
email.To ="收件者"
email.Subject ="主旨"
email.HtmlBody ="內容"
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1" 'SMTP Server
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "帳號"
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "密碼"
email.Configuration.Fields.Update
email.Send
Set email = nothing
%>
mail 物件介紹
名稱 |
功能 | 格式 |
Attach | 添加附件 | SubAttachFile(Source,[FileName],[EncodingMethod]) |
AttachURL | 以格式添加附加和數據 | SubAttachURL(Source,ContentLocation,[ContentBase],[EncodingMethod]) |
BCC | 以“,”分隔的接收者列表(暗送) | 字符串類型屬性 |
Body | TextHTML
|
字符串類型屬性 |
bodyformat | 郵件正文格式 | 0:HTMl1:Text |
CC | 以“,”分隔的接收者列表(抄送) | 字符串類型屬性 |
ContentBase | 帶有附件的郵件中正文采用的基地址 | 字符串類型屬性 |
ContentLocation | 帶有附件的郵件中正文采用的 | 字符串類型屬性 |
From | 郵件發送方地址 | 字符串類型屬性 |
Importance | 郵件級別 | 0:12: |
Send | 發送郵件 | SubSend([From],[To],[Subject],[Body],[Importance])各個參數可以參考上下文屬性 |
SetLocaleIDs | 設置新消息的代碼頁標識 | SubSetLocaleIDs(CodePageIDAsLong) |
Subject | 郵件主題 | 字符串類型屬性 |
To | 以“,”分隔的接收者地址列表 | 字符串類型屬性 |
Value | 任意的郵件頭的值 | 字符串類型屬性 |
Version | 當前集合數據對像庫()的版本號 | 只讀字符串類型屬性 |
幾個參考網址:
http://blog.pixnet.net/annyhunt/post/12094260
http://blog.blueshop.com.tw/hammerchou/archive/2006/06/18/29105.aspx
http://www.w3schools.com/asp/asp_send_email.asp
留言列表