Web Hosting Talk







View Full Version : need some .asp email form help


tonomud
04-20-2006, 11:38 AM
I have an existing .asp form email script that I want to slightly modify. Currently, the script is on a site, and when the submit button is pressed, the form data is emailed to an address which is hardcoded into the form.

I want to modify the script so that it's more like one of those "email this message to my friend whose email address I've just typed in" scripts. So...basically, I need to figure out how to put the variable (the email address that's typed into the "email address" field of the form). I'm assuming this is pretty easy to do, but I'm not familiar with ASP scripting--I'm more of a PHP person.

Any ideas would be appreciated! Thanks!


<%
if Request.Form("Name") <> "" then

Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "mail.server.org" ' Specify a valid SMTP server
Mail.From = "mail@server.org" ' Specify sender's address
Mail.FromName = "server.org" ' Specify sender's name

Mail.AddAddress "email@address.com"
if Request.Form("MailingList") <> "" then
Mail.AddCC "email@address.com"
end if
Mail.AddReplyTo "email@address.com"

Mail.Subject = "email from a friend"

BodyText = "Here's the body of the email" & vbcrlf
BodyText = BodyText & "---------------------------------------------------" & vbcrlf & vbcrlf
BodyText = BodyText & "Class: " & Request.Form("Class") & vbcrlf
BodyText = BodyText & "Name: " & Request.Form("Name") & vbcrlf
BodyText = BodyText & "Email: " & Request.Form("Email") & vbcrlf
BodyText = BodyText & "Phone: " & Request.Form("Phone") & vbcrlf
BodyText = BodyText & "Address: " & Request.Form("Address") & vbcrlf
BodyText = BodyText & "City, State/Zip: " & Request.Form("City") & ", " & Request.Form("State") & " " & Request.Form("Zip") & vbcrlf
BodyText = BodyText & "Addition Information: " & Request.Form("AdditionalInfo") & vbcrlf
if Request.Form("MailingList") <> "" then
BodyText = BodyText & "Add to mailing list." & vbcrlf
end if
BodyText = BodyText & "---------------------------------------------------" & vbcrlf & vbcrlf

Mail.Body = BodyText

On Error Resume Next
Mail.Send
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
Else
Response.Write "<font face='verdana' size=2><p><br><p><br><p><br><p><br><p><br><p align=center>"
Response.Write "<b>thanks for sending the email<br>the person will receive their email soon.</b><br><br><a href='javascript:window.close();'>Close this Window</a>"
End If

set Mail = nothing

Else

%>

tonomud
04-20-2006, 04:15 PM
I figured it out.

just had to change this line:

Mail.AddAddress Request.Form("Email")