2008年12月20日 星期六

ASP 郵寄元件

最近突然USER反應電子報無法寄件,於是前後換了CDONTS & CDO & JMail去測試
雖然,最後的結果很令人噴飯,不過還是整理了在ASP裡可用的郵寄元件分享一下..
PS.電子報請自動加入迴圈執行

[CDONTS]
Set mail = Server.CreateObject( "CDONTS.NewMail" )
mail.To = RS.Fields("EMail").Value
mail.From = CMail
mail.Subject = Upload("Tit")
mail.BodyFormat = 0
mail.MailFormat = 0
mail.Body = Content
mail.Send

[CDO]
Set objEmail = CreateObject("CDO.Message")
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "msa.hinet.net"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xx"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xx"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.From = CMail
objEmail.To = RS.Fields("EMail").Value
objEmail.Subject = Upload("Tit")
objEmail.HTMLbody = Content
objEmail.Configuration.Fields.Update
objEmail.Send
Set objEmail=Nothing

[JMail]
Set JMail = Server.CreateObject("JMail.Message")
JMail.Subject = Upload("Tit")
JMail.ContentType = "text/html"
JMail.Charset = "big5"
JMail.Encoding = "base64"
JMail.ISOEncodeHeaders = False
JMail.Priority = 3
JMail.From = CMail
JMail.AddRecipient RS.Fields("EMail").Value
JMail.silent = true
JMail.Body = Content
JMail.Send("msa.hinet.net")
set JMail = nothing

##EasyReadMore##