Solved

Using gmail smtp for cdosys

Posted on 2011-02-16
10
1,319 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to remove Duplicates from Generic List in Csharp 5 82
two submit buttons one form 15 87
Summernote required 3 141
JS does not refresh 6 21
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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 bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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