瘦鱼-博客

VBScript使用CDO.Message发送邮件

 1 Const Email_From = "from@163.com"
 2 Const Password = "password"
 3 Const Email_To = "to@qq.com"
 4 Set CDO = CreateObject("CDO.Message")
 5 CDO.Subject = "Test"
 6 CDO.From = Email_From
 7 CDO.To = Email_To
 8 CDO.TextBody = "Hello world!"
 9 Const schema = "http://schemas.microsoft.com/cdo/configuration/"
10 With CDO.Configuration.Fields
11 .Item(schema & "sendusing") = 2
12 .Item(schema & "smtpserver") = "smtp.163.com"
13 .Item(schema & "smtpauthenticate") = 1
14 .Item(schema & "sendusername") = Email_From
15 .Item(schema & "sendpassword") = Password
16 .Item(schema & "smtpserverport") = 25
17 .Item(schema & "smtpusessl") = True
18 .Item(schema & "smtpconnectiontimeout") = 60
19 .Update
20 End With
21 CDO.Send 

将以上代码保存成sendemail.vbs,通过命令进入到该目录下,输入sendemail.vbs执行。

 

VBScript在windows环境下调试,命令中输入cscript sendemail.vbs //x,可以进入VS环境调试。

posted @ 2015-07-31 21:48  瘦鱼  阅读(1677)  评论(0编辑  收藏  举报