Forum Moderators: open
Mailer.FromName = Request.QueryString("FIRST_NAME")
I tried this and it did not work ("FIRST_NAME") & ("LAST_NAME")
Mailer.FromName = Request.Form("FIRST_NAME") & " " & Request.Form("LAST_NAME")
I think that will work for you.
It's a good idea to filter your form input through a function you can write that will only allow acceptable characters in the form's input to keep hackers at bay and keep your input string clean. I also like to limit the length of each form's input and I do that as a parameter that's passed to the function that scans each form element.
[Edited for clarity.]
[edited by: GaryK at 5:32 pm (utc) on May 9, 2003]
<%
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "smtp.myhost.com"
Mailer.FromName = Request.QueryString("FIRST_NAME") & " " & Request.Form("LAST_NAME")
Mailer.FromAddress = "postmaster@mydomain.com"
Mailer.AddRecipient Request.QueryString("addressto"), Request.QueryString("addressto")
Mailer.Subject = "AutoMail_NEW_SUB!"
Mailer.BodyText = Request.QueryString("txtmsg")
Mailer.BodyText = Request.QueryString("FIRST_NAME")
Mailer.BodyText = Request.QueryString("LAST_NAME")
Mailer.BodyText = Request.QueryString("EMAIL_ADDRESS")
Mailer.BodyText = Request.QueryString("ZIP_CODE")
if not Mailer.SendMail then
Response.Write " Mailing Failed... Error is: <br>"
Response.Write Mailer.Response
else
Response.Write "sent successfully Thank You.<p>"
end if
%>
But you still have another problem area. Each time you assign some form input to BodyText you're overwriting what was there before. This would work better:
Mailer.BodyText = _
Request.Form("txtmsg") & vbCrLf & _
Request.Form("FIRST_NAME") & vbCrLf & _
Request.Form("LAST_NAME") & vbCrLf & _
Request.Form("EMAIL_ADDRESS") & vbCrLf & _
Request.Form("ZIP_CODE")