VB/VBS 发送邮件代码
NameSpace = "http://schemas.microsoft.com/cdo/configuration/" Set Email = CreateObject("CDO.Message") Email.From = "Benio_Guo@sohu.com" Email.To ="Benio_Guo@126.com" Email.Subject = "say hello" Email.Textbody = " test body " Email.AddAttachment "" With Email.Configuration.Fields .Item(NameSpace&"sendusing") = 2 .Item(NameSpace&"smtpserver") = "smtp.sohu.com" .Item(NameSpace&"smtpserverport") = 25 .Item(NameSpace&"smtpauthenticate") = 1 .Item(NameSpace&"sendusername") = "benio_guo" .Item(NameSpace&"sendpassword") = "q1w2e3" .Update End With Email.Send 下面是 vb版 Private Sub Form_Load()
|
Set cdo = CreateObject( "CDO.Message ")
strCfg = "http://schemas.microsoft.com/cdo/configuration/ "
With cdo
.Sender = "发送者邮件地址 "
.From = "发送者邮件地址 "
.To = "接收者邮件地址 "
.Fields( "urn:schemas:mailheader:X-Priority ") = 1
.Fields.Update
.Subject = "邮件标题 "
.TextBody = "邮件内容 "
.Configuration(strCfg & "SendUsing ") = 2
.Configuration(strCfg & "smtpserver ") = "发送邮件服务器地址 "
.Configuration(strCfg & "sendusername ") = "发送者邮箱帐号 "
.Configuration(strCfg & "sendpassword ") = "发送者邮箱密码 "
.Configuration.Fields.Update
.send
End With
msgbox "发送完成 "
set Email = CreateObject("CDO.Message")
Email.From = "Benio_Guo@cn.*.com"
Email.To = "Benio_Guo@cn.*.com"
Email.Subject = " Daily Planned Order Report_"&year(now())&month(now())&day(now())
'x="C:\test.txt"
y="K:\ASCP\reports\APS_PLAN_ORDER_FOR_RELEASE_BY_WEEKLY_DR.xls"
'Set fso=CreateObject("Scripting.FileSystemObject")
'Set myfile=fso.OpenTextFile(x,1,Ture)
'c=myfile.readall
'myfile.Close
'Email.Textbody = c
Email.AddAttachment y
with Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = "dm01"
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") = "benio guo"
.Item(NameSpace&"sendpassword") = "*pwd*"
.Update
end with
Email.Send
Set Email=Nothing
成长
/ | \
学习 总结 分享
QQ交流群:122230156
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步