You are here: Experts > Computing/Technology > Business Software > Active Server Pages Programming (ASP) > Using CDOSYS in ASP email for 1st time...can't resolve error...
Expert: Jeff Allen
Date: 9/14/2006
Subject: Using CDOSYS in ASP email for 1st time...can't resolve error...
Question Jeff,
Experimenting with email form in ASP at http://hwashington.ccc.edu/oit/oitreserve.asp. Processing page is at http://hwashington.ccc.edu/oit/sendmail.asp. I want the email to send a message that is formatted with line breaks to separate the different fields in the actual email message once the email is sent to the person who will receive the form contents.
Code is crashing in the With objMessage section (possibly due to strBody), and I can't figure out why:
Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Dim objConfig
Dim objMessage
Dim strBody
Dim Fields
strBody = "Instructor name: " & Request.Form("iname") & "<br>" & "Instructor email: " & Request.Form("iemail") & "<br>" & "Instructor phone #: " & Request.Form("iphone") & "<br>" & "Computer Lab Requested: " & Request.Form("labnum") & "<br>" & "Date Lab Needed: " & Request.Form("date") & "<br>" & "Additional Audio/Visual Needs: " & Request.Form("avneeds")
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
With Fields
.Item(cdoSendUsingMethod) = 2
.Item(cdoSMTPServer) = "mail2.ccc.edu"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.To = Request.Form("receiver")
.From = Request.Form("iemail")
.Subject = Request.Form("subject")
.HTMLBody = strBody
'.TextBody = strBody
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
Response.Redirect "http://hwashington.ccc.edu/oit/index3.asp"
Answer Is there a specific Error code you are receiving?
Have you looked at http://classicasp.aspfaq.com/email/how-do-i-send-e-mail-with-cdo.html which explains how sending email with CDo works and http://classicasp.aspfaq.com/email/why-does-cdo-message-give-me-8004020f-errors.... which explains Why does CDO.Message give me 8004020F errors..
Add to this Answer
Ask a Question