Click to See Complete Forum and Search --> : Sending E-mails with attached info!


AnaFyr
12-03-2003, 01:37 AM
Sending an e-mail with info returned to me as a post.

How could I write a script to handle sending an e-mail to someone with the values of a form.

Example:

This is what comes thru the "Post" method:

i.e.:

FirstName=John
LastName=Smith
Address=123 Any Street
Email=abc@example.com


I want to create a "Response" to this info. I will be sending values to a server. The server can automatically return the values back to me. I want to send an e-mail to the e-mail specified in the e-mail field of the "Post" collection.

i.e.:
I want to send abc@example.com, the results of the Name/Value pairs sent to the server.


I think it's something like:

If Form.Collection = "e-mail" Then

Response.Write "(Session.Document.Execute = 'mailto:// & '" e-mail "' &'"

Response.Write (Form.Collection) & "<BR>"

Next




Does this make sense...???

Help!

lillu
12-03-2003, 08:00 AM
Well, you can't Response.Write the mailto as it will not send the email invisibly. You will have to use one of the Mail objects in ASP. (eg. CDONTS)

Here are the steps:

1. First make the form

<form method="GET" action="getuserinput.asp">
First Name:
<input type="text" name="fname" size="20" value="" />
Last Name:
<input type="text" name="lname" size="20" value="" />
E-mail:
<input type="text" name="email" size="20" value="" />

<input type="submit" value="Submit" />
<input type="reset" value="Reset" />

</form>

2. submit the input as querystring to getuserinput.asp or whatever you want to call it, create objects then populate fields of the email from the submitted form

<%
Set Mail=Server.CreateObject(“CDONTS.NewMail”)
Mail.From=”put your email here”
Mail.Subject=”put some text you want for subject”
Mail.Body=Request.QueryString(“fname”) & Request.QueryString(“lname”)
Mail.To=Request.QueryString(“email”)
Mail.Send
Set Mail=Nothing
%>

This is just the idea, you may have to format the body a little bit with line breaks ( & vbcrlf & ) etc. Anything that just appears as text, should be double quoted eg.

Mail.Body = "First name: " & Request.QueryString("fname")

Also very important to do some form validation unless you want undeliverable message alerts.

Hope this is what you're looking for.