在Excel里如何直接发送邮件(电脑已经配置好OUTLOOK)?

2020-09-18 教育 133阅读
给段代码自己看
Private Sub Command1_Click()
strName = "http://schemas.microsoft.com/cdo/configuration/"
Set objEmail = CreateObject("CDO.Message")
Command1.Enabled = False
objEmail.From = "发送邮箱" '指定发送的邮箱
objEmail.To = "目的邮箱" '指定目的邮箱
objEmail.Subject = "hello" '主题
objEmail.TextBody = "nihao" '发送的内容
objEmail.Configuration.Fields.Item(strName & "sendusing") = 2
objEmail.Configuration.Fields.Item(strName & "smtpserver") = "smtp.qq.com" '服务器
objEmail.Configuration.Fields.Item(strName & "smtpserverport") = 25
objEmail.Configuration.Fields.Item(strName & "smtpauthenticate") = 1
objEmail.Configuration.Fields.Item(strName & "sendusername") = Left("发送邮箱", InStr("发送邮箱", "@") - 1)
objEmail.Configuration.Fields.Item(strName & "sendpassword") = "密码" '密码
objEmail.Configuration.Fields.Update
objEmail.Send
Command1.Enabled = True
End Sub
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com