新建一个后缀名为vbs的文件,把中文替换成对应的信息后,双击即可发送,内容文件的编码应为utf-8
NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
set Email = CreateObject("CDO.Message")
Email.From = "发件人地址"
Email.To = "收件人地址"
Email.Subject = "测试"
x="内容文件的绝对路径"
'y="附件绝对路径"
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") = "邮箱服务器"
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") = "用户名"
'此处的用户名和密码为邮箱服务器的登录用户的邮箱和密码
.Item(NameSpace&"sendpassword") = "密码"
.Update
end with
Email.Send
Set Email=Nothing