ASP 上配合 JMAIL 物件使用 SMTP 驗證發信, 請參考下列程式範例:
<%
Set jmail = Server.CreateObject("JMail.Message")
jmail.silent = true '例外錯誤,返回FALSE跟TRUE兩值
jmail.logging = true '啟用郵件記錄
'輸入您的STMP伺服器名稱
smtpServer = "mail.yourdomain.com"
'郵件帳號如需要密碼認證,請輸入您郵件帳號密碼才能發信
jmail.MailServerUserName = "yourname@yourdomain.com" '郵件帳號驗證名稱
jmail.MailServerPassword = "yourpassword" '郵件帳號驗證密碼
jmail.AddRecipient "someone@name.com", "yourname" '收信人的電子郵件位址
jmail.From = "you@yourdomain.com" '寄信人的電子郵件位址
jmail.ISOEncodeHeaders = false
jmail.ContentTransferEncoding = "base64"
msg.Encoding = "base64"
msg.Charset = "big5"
jmail.Subject = "郵件測試圖片"
jmail.Body = ""
' 將圖片附檔夾入信件中
contentId = jmail.AddAttachment("c:\picture.gif")
' 信件 HTML 本文
jmail.HTMLBody = "<html><head><meta http-equiv=""Content-Type"" content=""text/html; charset=big5""></head>"
jmail.appendHTML "<body><font color=""red"">圖片:</font><br>"
jmail.appendHTML "<img src=""cid:" & contentId & """>"
jmail.appendHTML "<br><br>郵件測試</body></html>"
jmail.Send( smtpServer) '指定送信伺服器 SMTP, 並發送郵件
%> |