Link to home
Start Free TrialLog in
Avatar of Bob Schneider
Bob SchneiderFlag for United States of America

asked on

Sending CDO SMTP Mail via gmail

I need to convert my email send capabilities of my web site to use my gmail account.  I could use some help modifying this code to work.  Thanks!!

			Set cdoConfig = CreateObject("CDO.Configuration")
			With cdoConfig.Fields
				.Item(cdoSendUsingMethod) = cdoSendUsingPort
				.Item(cdoSMTPServer) = "old.server"
				.Item(cdoSMTPAuthenticate) = 1
				.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
				.Item(cdoSendUsername) = "your_mom"
				.Item(cdoSendPassword) = "pwd"
				.Update
			End With

			Set cdoMessage = CreateObject("CDO.Message")
			With cdoMessage
				Set .Configuration = cdoConfig
				.To = sEvntDirEmail
				.From = sEmail
				.Subject = sEventName & " Contact: " & sSubject
				.TextBody = sMsg
				.Send
			End With
			Set cdoMessage = Nothing

Open in new window

SOLUTION
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob Schneider

ASKER

Ok padas, I tried that but got a "Name Redefined" error on this line:

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.

Except I know it is not elsewhere in the page.  Could it be from this portion of my global.asa page?

<!-- 
METADATA 
TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library"
-->

Here is my entire code:
            Const cdoSendUsingPickup = 1 
            Const cdoSendUsingPort = 2
            Const cdoAnonymous = 0 
            Const cdoBasic = 1
            Const cdoNTLM = 2

            Set objMessage = CreateObject("CDO.Message") 
            objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
            objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
            objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
            objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "your_mom"
            objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "pwd"
            objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
            objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
            objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
            objMessage.Configuration.Fields.Update
            objMessage.Subject = sSubject 
            objMessage.From = sEmail 
            objMessage.To = "bobs@h51software.net" 
            objMessage.TextBody = sMsg
            objMessage.Send

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
carrzkiss, I will look at it in the morning....heading to bed...your persistence is much appreciated!!!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
carzkiss, I got a "Transport can't connect to the server..." error.  I even reset my password to ensure that I had that correct.  Any ideas?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect!  Thanks!!  I will now spend the time to change all of my web code to reflect this.  padas, thanks for the include idea.  Here is my last question: I use includes for my headers, menus, etc.  How can I stick an include inside a block of asp script????
Excellent!  Thanks!!
<%if something="else" then%>
<!--#include file="get.asp"-->
<%else%>
<!--#include file="it.asp"-->
<%end if%>

You cannot put it like this.

<%if something="else" then
<!--#include file="get.asp"-->
%>

So, do the first one set above, and you will be good to go.
(this is the way I do mine, I have as many as 100+ files per project, and everything is included, depending on Queries from the database (or) URL)

Have a good one.
Carrzkiss
So if I have:
<%
lots
and
lots
of
lines
of
code
%>

I can break it anywhere to insert an include?

<%
lots
and
lots
>%
<!--#include file="get.asp"-->
<%
of
lines
of
code
%>
Absolutely!

Lets say that you have a page, and within that page, you have 1000 lines of code.
Database Connections.
Page Layout
exc...

You can do it like this.
(Lets just say that you are using tables, as this is 90% of my work, I am trying to convert over to DIV, however, it is a slow process)

<table>
<tr>
<%if request.QueryString("Admin") then%>
<td>Admin Menu</td>
<%elseif request.QueryString("Admin") then%>
<td>Normal Menu</td>
<%end if%>

<%if rs("stack")="Even" then%>
<td>Your stacked content is here</td>
<%elseif rs("stack")="OffSet" then%>
<td>Your stacked content is going to fall off the face of the earth</td>
<%end if%>


<%if rs("Ads")="User1" then%>
<td>1st Right Ads</td>
<%elseif rs("Ads")="User2" then%>
<td>2nd Right Ads</td>
<%end if%>
</table>

Open in new window


With the above scenario, it first deals with a Querystring, to see which menu to show.
Then we look at Database records to see which content to show.
Then we also check the Database records, to see which ads to show which user.

It is that simple, and makes for really easy debugging.

You can find more example here
http://www.cffcs.com

Let me know if you need any more advice on this Dynamic Coding Subject.
I live for this type of projects :)

Carrzkiss
Incredibly helpful!  Thanks for going above and beyond on this one!!!
No problem.
I know sharing the Knowledge that I know, when I am able to.
I hope you guys are on the east coast - much too early!  Good luck!
Yep, East coast for me.
Woke up at 3:30am, and laid back down around 8:00am, and just got back up about 30 minutes ago.
Ha, I do that too.