Solved

Using gmail smtp for cdosys

Posted on 2011-02-16
10
1,323 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 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
Technology Partners: 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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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