嗨,这段代码从我的OFFICE.But外部运行良好,不在办公室工作,network...Is端口被阻塞,原因是?
密码就在这里。最后还提到了错误。
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")
错误:第52行,第1行,错误传输未能连接到服务器。代码:80040213..。
发布于 2010-12-10 11:37:21
发布于 2010-12-10 11:35:29
由于您使用的是GMAIL地址,我猜您不是在运行此脚本的同一台计算机上运行电子邮件服务器吧?
如果是这样,则必须将其配置为连接到远程服务器。本文描述了如何做到这一点:VBScript使用CDO发送电子邮件
查看名为“使用针对远程SMTP服务器的身份验证发送文本电子邮件”一节。
我认为服务器是smtp.googlemail.com,端口是587。
发布于 2013-02-19 16:50:42
如果您使用的是gmail的SMTP服务器,那么首先尝试在端口25上告诉smtp服务器og gmail。如果显示阻塞,请尝试端口465。这两种方法都应该有效。无论哪个端口是开放的,请使用yoru脚本上的端口。如果没有工作,你必须与你的网络管理员讨论。防火墙规则正在阻止您通过office LAN进行通信。
https://stackoverflow.com/questions/4408355
复制相似问题