Thứ Bảy, 26 tháng 11, 2011

ASP: Send mail using CDO

smtpserver = "smtp.gmail.com"
youremail = "xxx@gmail.com"
yourpassword = "xxx"

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")

Set objFields = ObjSendMail.Configuration.Fields
With objFields
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 'Use SSL for the connection
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = youremail
.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = yourpassword
.Update
End With

With ObjSendMail
.BodyPart.Charset = "utf-8"
.To = youremail
.Subject = "Tiếng Việt tốt"
.From = "nthaih@yahoo.com"
.HTMLBody = "<p style='color:red'>Tiếng Việt tốt </p> " ' we are sending a html email.. simply switch the comments around to send a text email instead
'.TextBody = strBody
End With

ObjSendMail.Send
Set objFields = Nothing
Set ObjSendMail = Nothing


Nguồn:
http://www.cjwsoft.com/paypal_email_via_gmail.asp
http://www.wysiwyg.co.il/asp-CDO-Message-Mail-utf8-Charset.asp

Không có nhận xét nào:

Đăng nhận xét