Solved

Using gmail smtp for cdosys

Posted on 2011-02-16
10
1,321 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
  • 4
  • 3
  • 3
10 Comments
 
LVL 4

Accepted Solution

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

Assisted Solution

by:yelbaglf
yelbaglf earned 250 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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 250 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 250 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 250 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 250 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

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 information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

821 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