我想用VBScript和CDO发送邮件

我想用VBScript和CDO发送邮件,vbscript,Vbscript,您好,这段代码在我办公室外面工作正常。但在办公室网络中不工作…端口被阻塞是原因吗 代码在这里。错误也在最后提到 MsgBox("Hello world") Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the netw

您好,这段代码在我办公室外面工作正常。但在办公室网络中不工作…端口被阻塞是原因吗

代码在这里。错误也在最后提到

MsgBox("Hello world")
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = """xyz"" <mymail@gmail.com>"
objMessage.To = "anothersmail@gmail.com"
objMessage.TextBody = "hi it's me...." & vbCRLF & "this is wrking so we hav solved the issue."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing ) = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver ) = "smtp.gmail.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ) = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername ) = "mymail@gmail.com"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword ) = "****************"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport ) = 465

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl ) = True

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout ) = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send
MsgBox("Hello world") 
MsgBox(“你好世界”)
Const CDOSENDUSINGPICKEP=1'使用本地SMTP服务分拣目录发送邮件。
Const cdoSendUsingPort=2'使用网络发送邮件(通过网络发送SMTP)。
Const cdoAnonymous=0'不进行身份验证
常量cdoBasic=1'基本(明文)身份验证
常数cdoNTLM=2'NTLM
Set objMessage=CreateObject(“CDO.Message”)
objMessage.Subject=“示例CDO消息”
objMessage.From=“”xyz”“”
objMessage.To=”anothersmail@gmail.com"
objMessage.TextBody=“你好,是我……”&vbCRLF&“这太糟糕了,所以我们已经解决了这个问题。”
'==此部分提供远程SMTP服务器的配置信息。
objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/sendusing ) = 2
'远程SMTP服务器的名称或IP
objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/smtpserver )=“smtp.gmail.com”
'身份验证类型,无,基本(Base64编码),NTLM
objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate )=cdoBasic
'您在SMTP服务器上的用户ID
objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/sendusername ) = "mymail@gmail.com"
'您在SMTP服务器上的密码
objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/sendpassword ) = "****************"
'服务器端口(通常为25个)
objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/smtpserverport ) = 465
'将SSL用于连接(False或True)
objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/smtpusessl )=正确
'连接超时(秒)(CDO尝试建立到SMTP服务器的连接的最长时间)
objMessage.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout ) = 60
objMessage.Configuration.Fields.Update
'==结束远程SMTP服务器配置节==
objMessage.Send
MsgBox(“你好,世界”)


错误:第52行,字符1,错误传输无法连接到服务器。代码:80040213..

由于您使用的是GMAIL地址,我猜您没有在运行此脚本的机器上运行电子邮件服务器

如果是这样,您必须将其配置为连接到远程服务器。本文介绍了如何做到这一点:

查看“使用远程SMTP服务器的身份验证发送文本电子邮件”一节


我认为服务器是smtp.googlemail.com,端口是587。

由于您使用的是GMAIL地址,我猜您没有在运行此脚本的同一台机器上运行电子邮件服务器

如果是这样,您必须将其配置为连接到远程服务器。本文介绍了如何做到这一点:

查看“使用远程SMTP服务器的身份验证发送文本电子邮件”一节

我想服务器是smtp.googlemail.com,端口是587。

在这里你可以找到许多例子


在这里,你可以找到许多例子,如果你使用的是gmail的SMTP服务器,那么首先尝试在端口25上远程登录gmail的SMTP服务器。如果显示阻塞,请尝试端口465。两者都应该有效。无论哪个端口是开放的,请使用yoru脚本上的端口。如果没有工作,你必须与你的网络管理员讨论。防火墙规则阻止您通过办公室局域网进行通信。

如果您使用的是gmail的SMTP服务器,请先尝试在端口25上远程登录SMTP服务器og gmail。如果显示阻塞,请尝试端口465。两者都应该有效。无论哪个端口是开放的,请使用yoru脚本上的端口。如果没有工作,你必须与你的网络管理员讨论。防火墙规则阻止您通过办公室局域网进行通信。

您好,正如您所说的,非常好,您提供的链接非常好。只有该链接才足以满足我的要求。谢谢,正如你所说的是非常好的,你提供的链接是非常好的。只有这个链接是足够的我的要求。谢谢