Welcome to my ASP Code Website

Send a Friend - Sending the Message



You've set up a button to encourage your visitors to Send a Friend a URL, and you've gathered the info from them. Now it's time to send the message.

The final step is in essence mostly a mailing script. If you haven't done ASP mailing scripts before, read my Sending Mail with ASP article.

Again, ignore the **********s :)

****************************

<%
ToEmail = Request.Form("receiver")
RecEmail = Request.Form("sender")
Comment = Request.Form("comment")

URL = Request.Form("url")

Subject = RecEmail & " would like you to look at this!"

Body = "A friend of yours, " & RecEmail & ", thought you'd enjoy reading an interesting article " & vbCrLf & _
"at http://www.XXXXXXXXX.com" & vbCrLf & vbCrLf & _
"Article URL: " & URL & vbCrLf & vbCrLf & _
"Your friend's comments: " & vbCrLf & _
Comment & vbCrLf & vbCrLf & _
"Visit this article and many other interesting articles at:" & vbCrLf & _
"http://www.XXXXXXXXXX.com"
Impt = 2
FromEmail = RecEmail

Dim objMail
set objMail = CreateObject("CDONTS.NewMail")
objMail.Send FromEmail,ToEmail,Subject,Body,Impt
set objMail = Nothing

Response.Redirect("emailthanks.asp?url=" & URL)
%>

*****************************

OK, the script takes in the URL and other info you gathered up, and sends a mail message out. Be sure to change the XXXXXXXXXs to your own website name of course! When it's done, it goes off to emailthanks.asp. You can have that page be just a regular generic 'thank you for emailing someone' page, and because the URL is passed in, you can have a link that says 'return to the URL you just came from' very easily.

ASP Mail Code and Troubleshooting