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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP FormMail

Status
Not open for further replies.

mgifford

Programmer
Jun 3, 2004
30
US
I got my forms to work and e-mail properly but have two questions:

1. How do I have it a copy sent to the person who fills the form out? It doesn't work to do Mailer.Addrecipient = Request.Form("email_address").

2. How can I make the email be sent in HTML format? It did not work to set Mailer.BodyFormat = 0 and Mailer.MailFormat = 0.

Here's the code I am using:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<%
Dim strMsgHeader, strMsgInfo, strMsgFooter

If Request.querystring("action")="send" then

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = Request.Form("name")
Mailer.FromAddress = Request.Form("email")
Mailer.RemoteHost = "mail.medflight.com"
Mailer.AddRecipient "Smokey Solze", "ssolze@medflight.com"
Mailer.AddRecipient "Marcy Gifford", "mgifford@medflight.com"
Mailer.Subject = "MedFlight PR Event Request"
' Mailer.BodyFormat = 0
' Mailer.MailFormat = 1

strMsgInfo = "General Information: " & vbCrLf
strMsgInfo = strMsgInfo & " Requesting Agency: " & Request.Form("agency") & vbCrLf
strMsgInfo = strMsgInfo & " Contact Name: " & Request.Form("name") & vbCrLf
strMsgInfo = strMsgInfo & " Email Address: " & Request.Form("email") & vbCrLf
strMsgInfo = strMsgInfo & " Contact Phone: " & Request.Form("phone") & vbCrLf
strMsgInfo = strMsgInfo & " Type Phone: " & Request.Form("type") & vbCrLf
strMsgInfo = strMsgInfo & " Cancel Phone: " & Request.Form("cancel") & vbCrLf & vbCrLf
strMsgInfo = strMsgInfo & "Event Information: " & vbCrLf
strMsgInfo = strMsgInfo & " Date of Event: " & Request.Form("date") & vbCrLf
strMsgInfo = strMsgInfo & " Type of Event: " & Request.Form("Nature_Event") & vbCrLf
strMsgInfo = strMsgInfo & " City: " & Request.Form("city") & vbCrLf
strMsgInfo = strMsgInfo & " County: " & Request.Form("county") & vbCrLf
strMsgInfo = strMsgInfo & " Time: " & Request.Form("time") & vbCrLf & vbCrLf
strMsgInfo = strMsgInfo & "Landing Zone Information: " & vbCrLf
strMsgInfo = strMsgInfo & " Where will helicopter land: " & Request.Form("heli_land") & vbCrLf
strMsgInfo = strMsgInfo & " LZ Location: " & Request.Form("lzlocation") & vbCrLf
strMsgInfo = strMsgInfo & " Obstructions: " & Request.Form("obstructions") & vbCrLf
strMsgInfo = strMsgInfo & " Latitude: " & Request.Form("lat") & vbCrLf
strMsgInfo = strMsgInfo & " Longitude: " & Request.Form("long") & vbCrLf
strMsgInfo = strMsgInfo & " Radio Frequency: " & Request.Form("radfreq") & vbCrLf
strMsgInfo = strMsgInfo & " PL Tone: " & Request.Form("pltone") & vbCrLf
strMsgInfo = strMsgInfo & " Latitude: " & Request.Form("lat") & vbCrLf
strMsgInfo = strMsgInfo & " Ground Contact Unit Number: " & Request.Form("ground_contact") & vbCrLf & vbCrLf
strMsgInfo = strMsgInfo & "Special Requests: " & vbCrLf
strMsgInfo = strMsgInfo & Request.Form("spec_requests") & vbCrLf

strMsgHeader = "Your submission has been forwarded to our Business Development staff. Someone will respond to your request within 5 business days. Thank you for your interest in MedFlight." & vbCrLf & vbCrLf
strMsgFooter = vbCrLf & "-----------------------------------" & vbCrLf & "NOTICE TO RECIPIENT: This e-mail is meant for only the intended recipient of the transmission, and may be a communication privileged by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of this e-mail is strictly prohibited. Please notify us immediately of the error by return e-mail and please delete this message from your system. Thank you in advance for your cooperation."
Mailer.BodyText = strMsgHeader & strMsgInfo & strMsgFooter

if Mailer.SendMail then
' Message sent Ok, redirect to a confirmation page
Response.Redirect (" else
' Message send failure
Response.Write ("An error has occurred.<BR>")
' Send error message
Response.Write ("The error was " & Mailer.Response)
end if

end if
%>
 
On the first part
1. How do I have it a copy sent to the person who fills the form out? It doesn't work to do Mailer.Addrecipient = Request.Form("email[!]_address[/!]").

I don't think you have anything in your form with the name "email_address".

I see this later in the code:

Code:
Mailer.FromAddress = Request.Form("email")

So this should work:
Code:
Mailer.Addrecipient = Request.Form("email")

On your second question, I'll take a look at some code I have and get back to you.

<.

 
With Mailer.Addrecipient = Request.Form("email"), I get a "Page Not Found" error.
 
Ok, I found the answer to your second question, this is how you send the email in HTML format:

Code:
Mailer.ContentType = "text/html"


<.

 
Thanks! The HTML works perfectly!

However, the Mailer.Addrecipient = Request.Form("email") still did not work. I get an error page when adding this piece of code.
 
I'm sorry damn I'm out of it today,

Try this:

Code:
Mailer.AddRecipient Request.Form("name"),
 Request.Form("email")

As long as the Request.Form("name") and Request.Form("email") look like the other data in the other AddRecipent
statements, this should work.

<.

 
Alright, that worked. It showed that the e-mail was sent in the To line and the properties showed the correct e-mail addresses, however, the e-mails were never received. They were not captured by the SPAM blocker. What now?
 
I really have no idea, sounds like it may have something to do with a firewall or permissions, but I will say that I am totally guessing.

<.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top