AllExperts > Experts 
Search      

Active Server Pages Programming (ASP)

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Active Server Pages Programming (ASP) Answers
Question Library

Ask a question about Active Server Pages Programming (ASP)
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Jeff Allen
Expertise
I can answer basic to intermediate questions related to Classic ASP.I can answer Intermediate to Advanced questions CSS& HTML, and basic questions about JavaScript and Ajax. I can also answer questions related to web page accessibility under US Section 508.

Experience
I have 8 years experience with HTML. I have been developing in ASP, VBScript and CSS for two years each. I also currently work as web developer.

Organizations
IWA-HWG

Education/Credentials
I have a BA in English with minors in Web Design and Scientific and Technical Writing

 
   

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...

Topic: Active Server Pages Programming (ASP)



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



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.