?
Solved

Using gmail smtp for cdosys

Posted on 2011-02-16
10
Medium Priority
?
1,341 Views
Last Modified: 2012-05-11
I am using a gmail account for my email "me@mydomain.com".  The server that is hosting the domain thinks it is also hosting the email server.  As a result, when emails are sent from the site using the smtp server on the server(using cdosys) they never get "out" to the real world.  Can I use a gmail server to do this and, if so, how?  Otherwise, are there any other options?

Thanks~
0
Comment
Question by:Bob Schneider
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 4

Accepted Solution

by:
ong-hh earned 1000 total points
ID: 34912937
0
 
LVL 11

Assisted Solution

by:yelbaglf
yelbaglf earned 1000 total points
ID: 34912938
Try something like this...

Dim objPasswd
objPasswd = "Password"

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). 

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Subject" 
objMessage.From = """From_Name"" <From@domain.org>" 
objMessage.To = "Email_Address@gmail.com; 5555555555@txt.att.net"
objMessage.TextBody = "Email Body." & vbCRLF & vbCRLF & "Continued."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Email_Address@gmail.com"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = objPasswd

'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") = True

'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") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

Open in new window

0
 

Author Comment

by:Bob Schneider
ID: 34913040
Usiing the first solution I get this error:

The "SendUsing" configuration value is invalid
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Bob Schneider
ID: 34913068
Actually I fixed that but now i get an error when I try to send.  Here is my code:

Dim sSchema, iMsg, iConf, sFlds

sSchema = "http://schemas.microsoft.com/cdo/configuration/"

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set sFlds = iConf.Fields

With sFlds
	.Item(sSchema & "sendusing") = 2
	.Item(sSchema & "smtpserver") = "smtp.gmail.com" 
	.Item(sSchema & "smtpserverport") = 465
	.Item(sSchema & "smtpauthenticate") = 1
	.Item(sSchema & "sendusername") = "username"
	.Item(sSchema & "sendpassword") =  "pword"
	.Item(sSchema & "smtpusessl") = 1
	.Update
End With

With iMsg
	.To = "bobs@h51software.net"
	.From = sEmail
	.Subject = "H51Software.net Email: " & sSubject
	.HTMLBody = sMsg
	Set .Configuration = iConf
	SendEmailGmail = .Send
End With

		
Set iMsg = Nothing
Set iConf = Nothing
Set sFlds = Nothing

Open in new window


Any ideas?
0
 
LVL 11

Assisted Solution

by:yelbaglf
yelbaglf earned 1000 total points
ID: 34913160
It seems the issue is with:

.From = sEmail

When I set it to something like the below, it works:

.From = "email@domain.com"

Is 'sEmail' dynamically filled via a form?
0
 
LVL 4

Assisted Solution

by:ong-hh
ong-hh earned 1000 total points
ID: 34913165
what is the error?
I did not get any error in my XP environment
0
 
LVL 4

Assisted Solution

by:ong-hh
ong-hh earned 1000 total points
ID: 34913171
With iMsg
      .To = "bobs@h51software.net"
      .From = <>
      .Subject = "H51Software.net Email: " & <>
      .HTMLBody = <>
      Set .Configuration = iConf
      SendEmailGmail = .Send
End With


You need to fill in the <> values
0
 

Author Comment

by:Bob Schneider
ID: 34914831
Yes it is a variable that is populated from a form.  Is there any way around that?
0
 
LVL 11

Assisted Solution

by:yelbaglf
yelbaglf earned 1000 total points
ID: 34915629
The first thing I would do is double-check all the form and variable names, ensuring there are not typos or mismatches.
0
 

Author Comment

by:Bob Schneider
ID: 34921691
I will do that but it was working in the old cdosys system.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question