emailvbscriptasp-classiccdo.message

Couldn't send message to SMTP server. Transport Error 0x80040217


I get this error when sending a mail through asp using gmail, I already used ports 465, 587 and 25 with same results

Dim mail dim email2 as string dim urlms as string

Dim mail 
dim email2 as string
dim urlms as string
				

mail = CreateObject("CDO.Message") 			
urlms = "http://schemas.microsoft.com/cdo/configuration/"	
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


Solution

  • It worked like a charm for my own mail server, but It fails with Gmail I don't know why....

    Anyway, I tried also without the plus to concatinate and didnt work either, finally I used this:

    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") ="somemail@yourserver.com" '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 = "someone@someone.net"
    ObjSendMail.Subject = "this is the subject"
    ObjSendMail.From = "someone@someone.net"
         
    ' 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

    And worked like a charm for my server but it didn't work for gmail.