email - 通过 VBS 脚本发送电子邮件

标签 email vbscript smtp

我正在尝试通过 VBS 发送电子邮件,但我不断收到错误消息。我希望它尽可能简单地发送电子邮件。
不起作用,出现此错误:

        Set objEmail = CreateObject("CDO.Message")
        objEmail.From = "othermail@hey.com"
        objEmail.To = "myemail@yahoo.com"
        objEmail.Subject = "thisisasubject" 
        objEmail.Textbody = "Here is the message"
        objEmail.Send
错误:

line: 6

Char: 1 error: The "sendusing"configuration value is invalid. 80040220

最佳答案

Set emailObj      = CreateObject("CDO.Message")

emailObj.From     = "dc@gail.com"
emailObj.To       = "dc@gail.com"

emailObj.Subject  = "Test CDO"
emailObj.TextBody = "Test CDO"

Set emailConfig = emailObj.Configuration

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")    = 2  
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1  
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")      = true 
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")    = "YourUserName"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "Password1"

emailConfig.Fields.Update

emailObj.Send

If err.number = 0 then Msgbox "Done"

关于email - 通过 VBS 脚本发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21973581/

相关文章:

java - 使用 SSL 连接通过 Gmail SMTP 服务器发送电子邮件通知

c# - 使用 Socket 和 SSL 的 SMTP 连接

java - 我在使用 Java Mail 发送的电子邮件中丢失了句号

windows - 从 VIM 发送电子邮件

vbscript - 我可以在vbscript中抛出错误吗?

vbscript - 使用 cscript.exe 而不是 wscript.exe 在 VBScript 中执行文件

ios - 通过电子邮件发送 protected PDF Objective-c

php - 是否可以将 sendmail 配置为默认使用 SMTP 身份验证(用于 PHP)?

php - 修改 PHP 电子邮件中的日期标题?

c# - VB 脚本代码不调用 c# 函数