2015-02-06 55 views
0

使用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

+1

我希望這不是你的**真實**證書,它會真的很愚蠢的發佈在像SO這樣的公共區域。 – Lankymart 2015-02-06 11:09:28

+0

查看[Google - IMAP和POP3入門](https://support.google.com/mail/troubleshooter/1668960?hl=zh-CN#ts=1665119,1665162),您的設置是正確的。 – Lankymart 2015-02-06 11:14:36

+0

不要擔心,我雖然我修復了它:P – Franchojavilondo 2015-02-10 11:19:41

回答

0

它的工作就像我自己的郵件服務器的魅力,但它無法與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。

0
// 
// MessageId: CDO_E_LOGON_FAILURE 
// 
// MessageText: 
// 
// The transport was unable to log on to the server. 
// 
#define CDO_E_LOGON_FAILURE    0x80040217L 

而且爲什麼您使用加上concatinate三個配置項。

您的代碼將所有事物變暗兩次。它將字串變暗。

您正在創建對象而不使用Set。

我懷疑你的代碼運行產生一個錯誤。

+0

它爲我自己的郵件服務器起到了很好的作用,但它使用Gmail失敗我不知道爲什麼 – Franchojavilondo 2015-02-09 11:16:40

0

注意:消息說明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" 
1

如果您使用的是兩步驗證在谷歌帳戶,那麼你需要更改設置要麼選擇將「啓用安全性較低的應用程序」或生成的應用程序的密碼,這將是16個字符,你需要用這個你代碼而不是實際的Gmail密碼。 https://www.google.com/settings/security/lesssecureapps

相關問題