必须在vbscript发送电子邮件时发出STARTTLS错误 [英] Must issue STARTTLS error for sending email in vbscript

查看:273
本文介绍了必须在vbscript发送电子邮件时发出STARTTLS错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试写一个vbscript来发送一封电子邮件给一个附件文件到另一个电子邮件。但是当我尝试在窗口cmd中执行脚本时,会显示错误消息服务器拒绝发件人。服务器响应为530 5.7.0。必须发出STARTLS

I try to write a vbscript to send an email with some attachment file to another email. But when I try to execute the script in the window cmd, it's show me error message "The server reject the sender.The server response was 530 5.7.0. Must issue STARTLS"

我尝试将端口更改为465或587,用于Google SMTP端口/加密。但它也不起作用

I try change the port to 465 or 587 for the Google SMTP port/encryption. But it's also not working

以下是我的vbscript:

Below is my vbscript :

Set email = CreateObject("CDO.Message")
email.Subject = "Test Email"
email.From = "kai7@gmail.com"
email.To = "kol@gmail.com"
email.TextBody = "Message Text."
email.AddAttachment "C:\Users\fuckYou\Desktop\Handover\v.txt"
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
email.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")      = true 
email.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")    = "username"
email.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "password"
email.Configuration.Fields.Update
email.Send
set email = Nothing


推荐答案

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 

你是missin g一个字段。

You are missing a field.

在您正在使用的帐户上检查您的收件箱。 Google正在阻止您从新程序登录。 点击来自Google的电子邮件中的链接

Check your inbox on the account you are using. Google is blocking you due a signin from a new program. Click link in email from google.

这是我的完整脚本,用户/密码被空白。确保从您的帐户的行是正确的。

This is my full script with user/password blanked. Make sure from line is correct for your account.

在命令提示符下运行它,您不必单击确定20次,

Run this in a command prompt to you don't have to click ok 20 times,

cscript //nologo script.vbs

Script.vbs

Script.vbs

On Error Resume next
Set emailObj      = CreateObject("CDO.Message")
emailObj.From     = "dc@gmail.com"

emailObj.To       = "dc@gmail.com"

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

Set emailConfig = emailObj.Configuration

For each f in emailConfig.Fields
    wscript.echo f.name & " " & f
Next

msgbox emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") 


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")    = "Dc"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "MyPassword"
emailConfig.Fields.Update

emailObj.Send

wscript.echo err.description

For each f in emailConfig.Fields
    wscript.echo f.name & " " & f
Next



If err.number = 0 then Msgbox "Done"

这篇关于必须在vbscript发送电子邮件时发出STARTTLS错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆