windows · 2010-08-24

vb发送Gmail邮件

使用vb来发送Gmail邮件,配合windows2003的performance来做进程监控,很实用也很方便,进程控制也可以,脚本的主要作用是发送邮件通知,触发动作可由performance来完成.

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
schema = "http://schemas.microsoft.com/cdo/configuration/"
Flds.Item(schema & "sendusing") = 2
Flds.Item(schema & "smtpserver") = "smtp.gmail.com" 
Flds.Item(schema & "smtpserverport") = 465
Flds.Item(schema & "smtpauthenticate") = 1
Flds.Item(schema & "sendusername") = "YourEmailAddress"
Flds.Item(schema & "sendpassword") =  "YourPassWord"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
With iMsg
.To = "Recipients"
.From = "YourName "
.Subject = "Email Title"
.HTMLBody = "YourMessageGoesHere"
.Sender = "YourName"
.Organization = "YourName"
.ReplyTo = "Recipients"
Set .Configuration = iConf
SendEmailGmail = .Send
End With

set iMsg = nothing
set iConf = nothing
set Flds = nothing