Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Email with ASP

Status
Not open for further replies.

Aislinn

Technical User
Aug 5, 2007
2
US
I've created a form that needs to be e-mailed as html to the chosen recipients via an ASP script. The server is running Windows Server 2003, Enterprise edition. I found the code below using Google; however, I have not been able to make it work.

I'm very new to ASP and would appreciate any assistance on how to do this.

Code:
<%

Set oMail = Server.CreateObject("CDO.Message") 
Set oMailConfig = Server.CreateObject ("CDO.Configuration") 

oMailConfig.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "localhost" 
oMailConfig.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25 
oMailConfig.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2 
oMailConfig.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 60 
oMailConfig.Fields.Update 

Set oMail.Configuration = oMailConfig 
oMail.From = "your-email@your-domain.com"
oMail.To = "recipient@another-domain.com"
oMail.Subject = "Here goes the email subject..."
oMail.HTMLBody = "Here goes the email body..."
oMail.Send 

Set oMail = Nothing 
Set oMailConfig = Nothing 

%>
 
Do you wish to use the SMTP service that is part of the IIS server or do you have some different mail server software running on the same or other server?

The reason I ask is that you've got SendUsing set to 2 but also localhost is specified and often when it is localhost you see a 1.
 
I would like to use the smtp service on the IIS server. Again I'm new to ASP, so any pointers are greatly appreciated. What should the code look like and what steps should I take to load/test this?
 
Just try the following:
Set oMail = Server.CreateObject("CDO.Message")

oMail.From = "your-email@your-domain.com"
oMail.To = "recipient@another-domain.com"
oMail.Subject = "Here goes the email subject..."
oMail.HTMLBody = "Here goes the email body..."
oMail.Send

Set oMail = Nothing

It works for me all the time. Without setting the configuration. The CDO object picks up the default settings and send email.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top