这期内容当中小编将会给大家带来有关VBS中怎么利用CDO.Message发送邮件,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
代码如下:
Const Email_From = "still.demon@gmail.com"
Const Password = "password"
Const Email_To = "380401911@qq.com"
Set CDO = CreateObject("CDO.Message")
CDO.Subject = "From Demon"
CDO.From = Email_From
CDO.To = Email_To
CDO.TextBody = "Hello world!"
cdo.AddAttachment = "C:\hello.txt"
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
With CDO.Configuration.Fields
.Item(schema & "sendusing") = 2
.Item(schema & "smtpserver") = "smtp.gmail.com"
.Item(schema & "smtpauthenticate") = 1
.Item(schema & "sendusername") = Email_From
.Item(schema & "sendpassword") = Password
.Item(schema & "smtpserverport") = 465
.Item(schema & "smtpusessl") = True
.Item(schema & "smtpconnectiontimeout") = 60
.Update
End With
CDO.Send
详细注释版:
复制代码 代码如下:
'Date: 2010/6/18
'Author: Demon
'QQ: 380401911
'E-mail: still.demon@gmail.com
'Website: http://demon.tw
Const Email_From = "ddd@163.com" '发件人邮箱
Const Password = "password" '发件人邮箱密码
Const Email_To = "380401911@qq.com" '收件人邮箱
Set CDO = CreateObject("CDO.Message") '创建CDO.Message对象
CDO.Subject = "From Demon" '邮件主题
CDO.From = Email_From '发件人地址
CDO.To = Email_To '收件人地址
CDO.TextBody = "Hello world!" '邮件正文
cdo.AddAttachment = "C:\hello.txt" '邮件附件文件路径
Const schema = "http://schemas.microsoft.com/cdo/configuration/" '规定必须是这个,我也不知道为什么
With CDO.Configuration.Fields '用with关键字减少代码输入
.Item(schema & "sendusing") = 2 '使用网络上的SMTP服务器而不是本地的SMTP服务器
.Item(schema & "smtpserver") = "smtp.gmail.com" 'SMTP服务器地址
.Item(schema & "smtpauthenticate") = 1 '服务器认证方式
.Item(schema & "sendusername") = Email_From '发件人邮箱
.Item(schema & "sendpassword") = Password '发件人邮箱密码
.Item(schema & "smtpserverport") = 465 'SMTP服务器端口
.Item(schema & "smtpusessl") = True '是否使用SSL
.Item(schema & "smtpconnectiontimeout") = 60 '连接服务器的超时时间
.Update '更新设置
End With
CDO.Send '发送邮件
上述就是小编为大家分享的VBS中怎么利用CDO.Message发送邮件了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注编程网行业资讯频道。