无法将消息发送到SMTP服务器。传输错误0x80040217
使用Gmail通过ASP发送邮件时,我得到这个错误,我已经使用的端口465,587和25相同的结果无法将消息发送到SMTP服务器。传输错误0x80040217
昏暗的邮件 暗淡EMAIL2作为字符串 昏暗urlms作为字符串
Dim mail
dim email2 as string
dim urlms as string
\t \t \t \t
mail = CreateObject("CDO.Message") \t \t \t
urlms = "http://schemas.microsoft.com/cdo/configuration/" \t
mail.Configuration.Fields.Item(urlms & "sendusing") = 2 'enviar usando port
mail.Configuration.Fields.Item(urlms & "smtpserver") = "smtp.gmail.com"
mail.Configuration.Fields.Item(urlms & "smtpserverport") = 465
mail.Configuration.Fields.Item(urlms & "smtpusessl") = True
mail.Configuration.Fields.Item(urlms & "smtpconnectiontimeout") = 60
mail.Configuration.Fields.Item(urlms + "smtpauthenticate") = 1
mail.Configuration.Fields.Item(urlms + "sendusername") = "" 'login
mail.Configuration.Fields.Item(urlms + "sendpassword") = "" 'password
mail.Configuration.Fields.Update
mail.Send
它的工作就像我自己的邮件服务器的魅力,但它无法与Gmail我不知道为什么反正....
,我也试过没有加上concatinate,并没有任何工作,终于我用这个:
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
'This section provides the configuration information for the remote SMTP server.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yoursite.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 ' or 587
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
' Google apps mail servers require outgoing authentication. Use a valid email address and password registered with Google Apps.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]" 'your Google apps mailbox address
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword" 'Google apps password for that mailbox
ObjSendMail.Configuration.Fields.Update
ObjSendMail.To = "[email protected]"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "[email protected]"
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"
ObjSendMail.Send
Set ObjSendMail = Nothing
http://somee.com/DOKA/DoHelpTopics.aspx?docode=false&thnid=102
和工作就像魅力为我的服务器,但它不适用于Gmail。
//
// MessageId: CDO_E_LOGON_FAILURE
//
// MessageText:
//
// The transport was unable to log on to the server.
//
#define CDO_E_LOGON_FAILURE 0x80040217L
而且为什么您使用加上concatinate三个配置项。
您的代码将所有事物变暗两次。它将字串变暗。
您正在创建对象而不使用Set。
我怀疑你的代码运行产生一个错误。
它为我自己的邮件服务器起到了很好的作用,但它使用Gmail失败我不知道为什么 – Franchojavilondo 2015-02-09 11:16:40
注意:消息说明LOGON ERROR。确保名称和密码是正确的。
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "[email protected]"
emailObj.To = "[email protected]"
emailObj.Subject = "Test CDO"
emailObj.TextBody = "Test CDO"
Set emailConfig = emailObj.Configuration
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") = "YourUserName"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password1"
emailConfig.Fields.Update
emailObj.Send
If err.number = 0 then Msgbox "Done"
如果您使用的是两步验证在谷歌帐户,那么你需要更改设置要么选择将“启用安全性较低的应用程序”或生成的应用程序的密码,这将是16个字符,你需要用这个你代码而不是实际的Gmail密码。 https://www.google.com/settings/security/lesssecureapps
我希望这不是你的**真实**证书,它会真的很愚蠢的发布在像SO这样的公共区域。 – Lankymart 2015-02-06 11:09:28
查看[Google - IMAP和POP3入门](https://support.google.com/mail/troubleshooter/1668960?hl=zh-CN#ts=1665119,1665162),您的设置是正确的。 – Lankymart 2015-02-06 11:14:36
不要担心,我虽然我修复了它:P – Franchojavilondo 2015-02-10 11:19:41