CDO Gmail issue-VBForums
Results 1 to 21 of 21

Thread: CDO Gmail issue

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    CDO Gmail issue

    Hello, I am new to this forum.

    We use Google Apps as our mail provider. I have been sending my CDO mail through go daddy prior, but I am starting to have some issues where their mail server is being tagged for SPAM and some of my website messages are not getting through. So I'm trying to switch to the Google SMTP server. I have done everything I can find online, yet I still get the following error message:

    CDO.Message.1 error '80040213'

    The transport failed to connect to the server.

    Here is my code:
    Code:
    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")
    Set Flds = iConf.Fields
    
    ' send one copy with Google SMTP server (with autentication)
    schema = "http://schemas.microsoft.com/cdo/configuration/"
    Flds.Item(schema & "sendusing") = 2
    Flds.Item(schema & "smtpserver") = "smtp.gmail.com" 
    Flds.Item(schema & "smtpserverport") = 465
    Flds.Item(schema & "smtpauthenticate") = 1
    Flds.Item(schema & "sendusername") = "myname@mydomain.com"
    Flds.Item(schema & "sendpassword") =  "mypassword"
    Flds.Item(schema & "smtpusessl") = 1
    Flds.Update
    
    With iMsg
    .To = "sendername"
    .From = "myname@mydomain.com"
    .Subject = "Test send with gmail account"
    .HTMLBody = message
    Set .Configuration = iConf
    SendEmailGmail = .Send
    End With
    
    set iMsg = nothing
    set iConf = nothing
    set Flds = nothing
    Any idea why I am getting this error?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    20,093

    Re: CDO Gmail issue

    i have a script for gmail, that was tested, working some time ago, but it no longer connects to their server, i have not yet found out why
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    Re: CDO Gmail issue

    Quote Originally Posted by westconn1 View Post
    i have a script for gmail, that was tested, working some time ago, but it no longer connects to their server, i have not yet found out why
    Perhaps something has changed with Google??

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    20,093
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    Re: CDO Gmail issue

    Quote Originally Posted by westconn1 View Post
    Thanks...I have not found a solution yet. If I do I'll certainly post. I was hoping someone here might have an answer as I'm running out of ideas.

  6. #6

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    Re: CDO Gmail issue

    OK...so I found a solution, but I'm not exactly sure why it works???? Can someone please help? The reason I say this is that there is no reference to sending through Google Apps. I found this on "Experts Exchange", tested it and it works. Here's the code

    vb Code:
    1. Set objCDOMail = Server.CreateObject("CDO.Message")
    2. Set iConf = CreateObject("CDO.Configuration")
    3. Dim Flds
    4. Set Flds = iConf.Fields
    5. Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
    6. Flds( _
    7.  "http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") _
    8.   = "c:\inetpub\mailroot\pickup"
    9. Flds.Update
    10. Set objCDOMail.Configuration = iConf
    11. objCDOMail.From    = "myemail@email.com"
    12.       objCDOMail.To      = "testemail@email.com"
    13.       objCDOMail.Subject = "Subject"
    14.       objCDOMail.HTMLBody = "Test"
    15.       objCDOMail.Send
    16.       Set objCDOMail = Nothing
    17.                    
    18.        If Err.Number = 0 Then
    19.       Response.Write "Thank you for you query, we will get back to your with 48hrs."
    20.  Else
    21.       Response.Write "There was a problem with your form, please use the browser back button and resubmit your question.  We are sorry for any inconvenience."
    22. End if

  7. #7
    PowerPoster
    Join Date
    May 2002
    Posts
    25,964

    Re: CDO Gmail issue

    It's sending it out using your default mail transport on your web server.
    That's what the "c:\inetpub\mailroot\pickup" path is... drop a properly formatted text file into there and the mail transport picks up the file and sends it. The 2 Flds of SendUsing and smtpserverpickupdirectory tell CDO what to do with the message when sending it. In this case, instead of being routed to an STMP Server using SMTP, it's being re-routed to the pickup folder. Just for fun, route it to the C:\ route and you should see a file created there with the message in it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    Re: CDO Gmail issue

    Thanks for clearing that up. So there should be no issue with me using this method to also add an attachment, correct?

  9. #9
    PowerPoster
    Join Date
    May 2002
    Posts
    25,964

    Re: CDO Gmail issue

    To be honest, I'm not sure... I've used this method before, but only to send out text-based emails, never attachments. Might want to just set up a test to find out. See how it goes. I wouldn't think there's a problem... but real-world and theory sometimes don't play along.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    Re: CDO Gmail issue

    My apologies for being lazy . I have tested, and for those that may read this down the line, yes it will work for attachments.

  11. #11
    PowerPoster
    Join Date
    May 2002
    Posts
    25,964

    Re: CDO Gmail issue

    Bonus!

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  12. #12

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    Re: CDO Gmail issue

    Hmmm...I'm starting to wonder now what this all really means...I apologize for my lack of expertise, but what exactly do you mean "default mail transport on your web server"? My domain name is owned by GoDaddy. My Mx records point to Google. Google Apps is my mail provider. I have a file server at the office with a domain but no SMTP mail server on it.

    So in this scenario, what is the default mail transport that is being used? I assume it is not my local server. I realize that you don't know my system but I'm just trying to figure out if GoDaddy owns my domain name, do they then by default become the default mail transport, thus giving me the same problem?

    I am asking because I got another "blocked for SPAM" message on one of our outgoing CDO messages with the returning server being GoDaddy. It was returned right around the same time as when I was making the above changes, so I can't be sure if this was before or after I made the change to the code. In other words, I'm wondering if I still have the same problem?

    Again, sorry for my lack of technical expertise in this area. Just trying to figure it all out so my legit emails don't get blocked because of something between Comcast and GoDaddy.

  13. #13
    PowerPoster
    Join Date
    May 2002
    Posts
    25,964

    Re: CDO Gmail issue

    "c:\inetpub\mailroot\pickup" <- that's pointing to your local drive... or at least the local drive where the app is running from. it would be the default SMTP server that is on that machine - I believe it's something that's part of IIS. I wouldn't be surprised to find out that if you checks the services running on that machine, if the "Mail Transport" Service was running.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  14. #14

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    Re: CDO Gmail issue

    hmmmm...don't see mail transport running in the services on this machine. Now, this is running from a web page, so could the "c:\intetpub..." refer to the local drive on the web host? If that's the case, it will just go back to GoDaddy in which case I haven't really made any change. I was hoping this meant it was going to refer to the local drive of the mail provider, but if I'm understanding you correctly that is probably not the case.

  15. #15
    PowerPoster
    Join Date
    May 2002
    Posts
    25,964

    Re: CDO Gmail issue

    Where is the code running? on the web server, right? So... where ever that location is, it's putting it into that folder on that machine. So it sounds like you are running this code on the webserver hosted at GoDaddy... so the C:\inetpub is on their server... odds are they DO have the mail transport running, otherwise the mails wouldn't be sent out.

    If you were to run that code on YOUR LOCAL machine instead and changed "c:\inetpub\mailroot\pickup" to "c:\" you would (or should) see files be created in your C Root folder... (not sure if they come through as txt, eml or msg)

    Now, it's possible they have their transport to pick up anything in the pickup folder and automatically mark it as spam and return it. But I'm not sure.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  16. #16

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    Re: CDO Gmail issue

    So I guess I really did nothing here as I already had it working on Godaddy directly accessing their SMTP server... the spam problems I was having is that comcast is flagging all messages from one of their servers as having come from a known spam server. I have called GoDaddy and asked them to investigate but nothing so far. So the emails that go out from my website to a comcast account account are bouncing. That is why I was trying to have them sent from the google smtp server, where I host my email, instead. But for some reason all the code I have found to make to make this work doesn't work, and it seems like something has changed in their system, because people have reported that code that used to work no longer works. So that's what led me to again seek an answer, and I thought I had one, but I guess I just ran around the block only to end up back home!

    Oh well..the search continues
    Thanks so much!

  17. #17
    PowerPoster
    Join Date
    Dec 2004
    Posts
    20,093

    Re: CDO Gmail issue

    i have in the past been able to send emails with cdo using GMX (another free smtp server)

    note any free server, may be more subject to being marked as a spam source
    i tested this today and sent email ok through gmx
    Last edited by westconn1; Apr 20th, 2010 at 06:00 PM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  18. #18

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    Re: CDO Gmail issue

    Thanks...I appreciate the help, but I'm going to first focus on trying to make it work with Google.

  19. #19
    PowerPoster
    Join Date
    Dec 2004
    Posts
    20,093

    Re: CDO Gmail issue

    i have tonight, actually got emails to go through gmail, but so far it has not arrived, but i did get notifications in my gmail inbox about invalid email addresses, so it must be working, and showing in my sent mail box

    edit: email arrived after about 15 minutes, don't know why it was not working last time
    Last edited by westconn1; Apr 21st, 2010 at 04:48 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  20. #20

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    11

    Re: CDO Gmail issue

    Thank you...where can I find the script that you used?

  21. #21
    PowerPoster
    Join Date
    Dec 2004
    Posts
    20,093

    Re: CDO Gmail issue

    vb Code:
    1. usernm = "user@gmail.com"
    2. pass = "mypass"
    3.       Set objmessage = CreateObject("CDO.Message")
    4.       objmessage.Subject = "Example CDO Message via gmail"
    5.       objmessage.From = "me@my.com"   ' gmail does not allow spoofing, it will always be from user@gmail
    6.       objmessage.To = "someone@somewhere.com" ' sent to valid email, not at gmail
    7.       objmessage.TextBody = "This is some sample message text."
    8.        
    9.        objmessage.Configuration.Fields.Item _
    10.       ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    11.        
    12.       'Name or IP of Remote SMTP Server
    13.        
    14.        
    15.       'Type of authentication, NONE, Basic (Base64 encoded), NTLM
    16.       objmessage.Configuration.Fields.Item _
    17.       ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    18.       'Your UserID on the SMTP server
    19.       objmessage.Configuration.Fields.Item _
    20.       ("http://schemas.microsoft.com/cdo/configuration/sendusername") = usernm
    21.        
    22.       'Your password on the SMTP server
    23.        
    24.       objmessage.Configuration.Fields.Item _
    25.       ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = pass
    26.       objmessage.Configuration.Fields.Item _
    27.       ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
    28.       'Server port (typically 25)
    29.       objmessage.Configuration.Fields.Item _
    30.       ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
    31.       'Use SSL for the connection (False or True)
    32.       objmessage.Configuration.Fields.Item _
    33.       ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
    34.       'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
    35.       objmessage.Configuration.Fields.Item _
    36.       ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
    37.       objmessage.Configuration.Fields.Update
    38.       objmessage.Send
    39.       Set objmessage = Nothing

    same script was not working when this thread started for some reason
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.