-
Mar 23rd, 2010, 10:31 AM
#1
Thread Starter
New Member
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?
-
Mar 23rd, 2010, 03:13 PM
#2
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
-
Mar 23rd, 2010, 03:47 PM
#3
Thread Starter
New Member
Re: CDO Gmail issue
Originally Posted by westconn1
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??
-
Mar 24th, 2010, 03:25 AM
#4
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
-
Mar 24th, 2010, 09:00 AM
#5
Thread Starter
New Member
Re: CDO Gmail issue
Originally Posted by westconn1
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.
-
Apr 15th, 2010, 08:44 AM
#6
Thread Starter
New Member
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:
Set objCDOMail = Server.CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") Dim Flds Set Flds = iConf.Fields Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1 Flds( _ "http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") _ = "c:\inetpub\mailroot\pickup" Flds.Update Set objCDOMail.Configuration = iConf objCDOMail.From = "myemail@email.com" objCDOMail.To = "testemail@email.com" objCDOMail.Subject = "Subject" objCDOMail.HTMLBody = "Test" objCDOMail.Send Set objCDOMail = Nothing If Err.Number = 0 Then Response.Write "Thank you for you query, we will get back to your with 48hrs." Else 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." End if
-
Apr 15th, 2010, 08:56 AM
#7
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
-
Apr 15th, 2010, 09:03 AM
#8
Thread Starter
New Member
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?
-
Apr 15th, 2010, 09:34 AM
#9
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
-
Apr 15th, 2010, 09:53 AM
#10
Thread Starter
New Member
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.
-
Apr 15th, 2010, 09:54 AM
#11
-
Apr 20th, 2010, 10:33 AM
#12
Thread Starter
New Member
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.
-
Apr 20th, 2010, 11:16 AM
#13
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
-
Apr 20th, 2010, 12:40 PM
#14
Thread Starter
New Member
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.
-
Apr 20th, 2010, 12:55 PM
#15
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
-
Apr 20th, 2010, 01:18 PM
#16
Thread Starter
New Member
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!
-
Apr 20th, 2010, 04:25 PM
#17
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 05: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
-
Apr 20th, 2010, 06:08 PM
#18
Thread Starter
New Member
Re: CDO Gmail issue
Thanks...I appreciate the help, but I'm going to first focus on trying to make it work with Google.
-
Apr 21st, 2010, 03:25 AM
#19
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 03: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
-
Apr 21st, 2010, 10:06 AM
#20
Thread Starter
New Member
Re: CDO Gmail issue
Thank you...where can I find the script that you used?
-
Apr 21st, 2010, 04:13 PM
#21
Re: CDO Gmail issue
vb Code:
usernm = "user@gmail.com" pass = "mypass" Set objmessage = CreateObject("CDO.Message") objmessage.Subject = "Example CDO Message via gmail" objmessage.From = "me@my.com" ' gmail does not allow spoofing, it will always be from user@gmail objmessage.To = "someone@somewhere.com" ' sent to valid email, not at gmail objmessage.TextBody = "This is some sample message text." objmessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Name or IP of Remote SMTP Server 'Type of authentication, NONE, Basic (Base64 encoded), NTLM objmessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'Your UserID on the SMTP server objmessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusername") = usernm 'Your password on the SMTP server objmessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = pass objmessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" '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") = 1 '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") = 30 objmessage.Configuration.Fields.Update objmessage.Send 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|