Send from Webpage using cdo

Hi, I inherited code that needs to work with my local SBS 2008 Exchange 2007 server.  This is the original code:

<!--#include virtual="/Include/incGUID.asp"-->

<%
strFirst = Request("First")
strLast = Request("Last")
strCompany = Request("Company")
strPhone = Request("Phone")
strCity = Request("City")
strState = Request("State")
strEmail = Request("Email")
strPassword = Request("Password")
strNow = Year(Date()) & "-" & Month(Date()) & "-" & Day(Date()) & " " & Hour(Now()) & ":" & Minute(Now()) & ":" & Second(Now())
strRecordKey = createGuid()


Set rs = CreateObject("ADODB.Recordset")
strSQL = "INSERT INTO tblpassloads (GUID, NameFirst, NameLast, Email, Company, City, State, Phone, Password, LastVisit, Approved, Entered, InBy) VALUES ('" & strRecordKey & "', '" & strFirst & "', '" & strLast & "', '" & strEmail & "', '" & strCompany & "', '" & strCity & "', '" & strState & "', '" & strPhone & "', '" & strPassword & "', '" & strNow & "', '0', '" & strNow & "', 'WebForm')"
rs.Open strSQL, Application("dbcConn")
Set rs = Nothing


'Send an html email with the VQ server
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

strHTML = "<html><head><title>Load List Request</title></head><body>There is a new request for load list access approval. You can view this request at <a href=""F*******r">http://www.f*******r.com/adminlogin"">F*******r A****</a>.</body></html>"

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Load List new password request"
objMessage.From = """F** *****r"" <j***@f*******r.com>"
objMessage.To = "j***@f*******r.com"
'objMessage.To = "m******n@g***l.com"
objMessage.HTMLBody = strHTML
'objMessage.CreateMHTMLBody "file://C:/Documents and Settings/k****i.F*******R/My Documents/LoadListStuff/LoadList.html"

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

'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") = "j***@f*******r.com"

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

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

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

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

 

Response.Redirect "SignUpAckn.asp"
%>

This code on a hosted web server asp page does not work.  I don't know what email server was used before and it is gone anyway.  Now I have an in-house SBS2008 / Exchange 2007 server which I would like to use to send this message from the hosted webpage.  Do I need to consider using a different server?  And how do I make this code

June 27th, 2013 8:36pm

I don't have E2007 any more, so I can't do any testing of this sort of code. But it looks like the code uses CDOEX. AFAIK, CDOEX is still available in E2007, so I'd have expected it to work. Does it produce any error messages?
Free Windows Admin Tool Kit Click here and download it now
June 28th, 2013 1:38pm

Here's how it's supposed to work:

Fill in the form on the webpage
Hit the Submit button
I get an email to approve the new user
In the background, the user is auto-added to the MySQL db.

I never get the email, no error message, nothing.  Lots to go on, huh. :)

June 28th, 2013 6:21pm

Sorry for the delay. For some reason, I'm not getting any email notifications from this forum since it was redesigned.

Anyway, you'll have to somehow find where the code is failing. If you aren't getting any error messages, you'll need to insert breakpoints in the code. For example, if you want to make sure that the recordset is properly created, you might change the line

Set rs = CreateObject("ADODB.Recordset")

to this

Set rs = CreateObject("ADODB.Recordset")
response.write "rs created okay<br>"
response.end

if you see the message display, remove the 'response.end' line and then move further up the code and do something similar. Eventually, you'll find the point where it seems to stop.

Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2013 5:12am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics