建立一个VBS文件,内容如下:
Dim Mail
Dim strCfg
Set Mail=CreateObject("CDO.Message")
strCfg="http://schemas.microsoft.com/cdo/configuration/"
Set Args=WScript.Arguments
With Mail
.Configuration(strCfg & "smtpauthenticate")=1
.Configuration(strCfg & "sendusing")=2
.Configuration(strCfg & "smtpserver")="smtp.xxx.com"
.Configuration(strCfg & "smtpserverport")=25
.Configuration(strCfg & "sendusername")="yourname@xxx.com"
.Configuration(strCfg & "sendpassword")="yourpass"
.Configuration.Fields.Update
.From="yourname@xxx.com"
.To="to@xxx.com"
.Subject="邮件标题"
.TextBody="邮件内容"
'或者.HtmlBody="邮件内容"
.AddAttachment "c:/boot.ini"'附件文件路径
'可以加多个附件.AddAttachment "c:/boot2.ini"'附件文件路径
.Fields.Update
End With
Mail.Send
Set Mail=Nothing
Set Args=Nothing
文中红色部分替换成实际值。
在windows下直接执行这个VBS文件即可。
本文介绍了一个使用VBS脚本发送带有附件的电子邮件的方法。通过设置SMTP服务器和认证信息,脚本能够从Windows环境下直接发送邮件。
4250

被折叠的 条评论
为什么被折叠?



