嗨这个代码在我办公室的外面工作正常。但不在办公室网络工作......端口被阻塞是原因??????
守则在这里。最后还提到了错误。
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 ..
答案 0 :(得分:1)
http://www.paulsadowski.com/WSH/cdo.htm
http://forums.aspfree.com/asp-development-5/cdo-message-1-error-80040220t-47913.html
这里你可以找到很多例子
答案 1 :(得分:0)
由于您使用的是GMAIL地址,我猜您没有在运行此脚本的同一台计算机上运行电子邮件服务器?
如果是这样,您必须将其配置为连接到远程服务器。本文介绍了如何执行此操作:VBScript To Send Email Using CDO
查看名为的部分,使用针对远程SMTP服务器的身份验证发送文本电子邮件。
我认为服务器是 smtp.googlemail.com ,端口是 587 。
答案 2 :(得分:0)
如果您正在使用gmail的SMTP服务器,那么首先尝试在端口25上telnet smtp服务器og gmail。如果它说阻止尝试端口465.要么应该工作。无论哪个端口都打开使用yoru脚本。如果没有,你必须与网络管理员讨论。防火墙规则阻止您通过办公室LAN进行通信。