最近公司需要个自动发送脚本,条件是需要网页中报表。查阅了一些资料终于完成,但是说的太笼统了。所以自己来测试后确认可以成功发送。
使用远程页面然后将网页内容发送到邮箱,这网页会实时显示。 代码如下仅仅需要更改配置文件。
wscript.echo "sending mail!" NameSpace = "http://schemas.microsoft.com/cdo/configuration/" Set objMessage = CreateObject("CDO.Message") smtp="" u="" p="" objMessage.Subject = "This is report" objMessage.From = "" objMessage.To = "" objMessage.Bcc = "" objMessage.Cc = "" objMessage.BodyPart.Charset = "UTF-8" objMessage.HTMLBody = "<h1>This is some sample message html.</h1>" objMessage.CreateMHTMLBody "D:\ProductionReport\total\total.html" objMessage.CreateMHTMLBody "file://D|/ProductionReport/total/totalASM.html" With objMessage.Configuration.Fields .Item(NameSpace&"sendusing") = 2 .Item(NameSpace&"smtpserver") = smtp .Item(NameSpace&"smtpserverport") = 25 .Item(NameSpace&"smtpauthenticate") = 1 .Item(NameSpace&"sendusername") = u .Item(NameSpace&"sendpassword") = p .update End With
objMessage.Send
Set objMessage = Nothing