<%
const email_from="[email protected]"
const password="fanlianghao"
const eamil_to="[email protected]"
file = "C:\hello.txt"
set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending mail with CDO"
myMail.From= email_from
myMail.TO= eamil_to
myMail.TextBody="This is a big srupise"
myMail.AddAttachment file'郵件附件檔案路徑
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
With myMail.Configuration.Fields '用with關鍵字減少代碼輸入
.Item(schema & "sendusing") = 2 '使用網路上的SMTP服務器而不是本地的SMTP服務器.Item(schema & "smtpserver") = "smtp.gmail.com" 'SMTP服務器地址
.Item(schema & "smtpauthenticate") = 1 '服務器認證方式
.Item(schema & "sendusername") = email_from '發件人郵箱
.Item(schema & "sendpassword") = Password '發件人郵箱密碼
.Item(schema & "smtpserverport") = 465 'SMTP服務器埠
.Item(schema & "smtpusessl") = false '是否使用SSL
.Item(schema & "smtpconnectiontimeout") = 60 '連接服務器的超時時間
.Update '更新設定
End With
myMail.Send '發送郵件
%>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/28656.html
標籤:VB基礎類
