本帖最后由 lss001 于 2020-1-23 16:35 编辑
Sub CDOMessages() Const sc = "http://schemas.microsoft.com/cdo/configuration/" '微软邮件服务器网址 Set cm = CreateObject("CDO.Message") '创建CDO对象 Withcm.Configuration.Fields .Item(sc & "sendusing") = 2 '使用网络上的SMTP服务器2而不是本地的SMTP服务器1 .Item(sc & "smtpserver") = "smtp.qq.com" 'qq/SMTP服务器地址 .Item(sc & "smtpserverport") = 465 'qq/SMTP服务器端口 .Item(sc & "smtpauthenticate") = 1 'qq/SMTP服务器认证方式 .Item(sc & "smtpusessl") = 1 '是否使用SLL加密方式/1是/0否 .Item(sc & "sendusername") = "xxx@qq.com" '发件人邮箱地址 .Item(sc & "sendpassword") = "16位授权码" '发件人邮箱16位<POP3/SMTP服务>授权码//必须填写 '如何开通POP3/SMTP服务<以下qq邮箱为例>: '登录网页版qq邮箱/设置/账户/<POP3/SMTP服务>开启/<复制16位授权码后>确定/保存更改 .Item(sc & "smtpconnectiontimeout") = 60 '连接服务器的超时时间/秒数 .Update '更新设置 End With With cm .From = "xxx@qq.com" '发件人邮箱地址 .To = "yyy@qq.com" '收件人邮箱地址 .Cc = "xxx@qq.com" '抄送人邮箱地址 '.Bcc = "xxx@qq.com" '密抄人邮箱地址 '.BodyPart.Charset = "utf-8" '邮件内容编码 .Subject = "From Demon!" '邮件主题 .TextBody = "Hello world!" '邮件正文//文本格式 '.htmlBody = "<h1>Hello world!</h1>" '邮件正文//网页格式 '.CreateMHTMLBody"abc.html" '邮件正文//网页文件格式 .AddAttachment "G:\abc.txt" '邮件附件文件路径 .Send '发送邮件 End With End Sub
|