View Full Version : Email article script edit to email more than one

03-29-2006, 08:12 PM
I need to edit my current "Email this article" ASP form that uses JMail. It currently allows the user to email one friend an article. I want the user to be able to email the article to more than one friend. Also; I'd like to limit the total number of recipients to five. Any assistance would be greatly appreciated. Below is my current code for the form and action pages.

------- email_article.asp -------
<FORM action="email_article_confirm.asp" method="post" name="Emailthispage">

strURL = Request.ServerVariables("HTTP_Referer")

IF strURL = "" THEN
Response.Write "Sorry, your browser does not support this function."

<p><b>Page Link:</b> <%= strURL %></p>

<TABLE border="0">
<TR><TD>Your email:<br><input type="text" name="YourEmail" size="40"></TD></TR>
<TR><TD>Your first name:<br><input type="text" name="YourName" size="40"></TD></TR>
<TR><TD>Recipient's email:<br><input type="text" name="RecipEmail" size="40"></TD></TR>
<TR><TD>Recipient's first name:<br><input type="text" name="RecipName" size="40"></TD></TR>
<TR><TD>Comments:<br><TEXTAREA name="Comments" cols="50"></TEXTAREA></TD></TR>

<input type="hidden" name="URL" value="<%= strURL %>">
<input type="submit" value="Submit">

------- email_article_confirm.asp -------
DIM objJMail
strYourEmail = Request.Form("YourEmail")
strYourName = Request.Form("YourName")
strRecipEmail = Request.Form("RecipEmail")
strRecipName = Request.Form("RecipName")
strComments = Request.Form("Comments")
strURL = Request.Form("URL")

Set objJMail = Server.CreateObject("JMail.SMTPMail")
objJMail.ServerAddress = "REMOVED FOR FORUM POST"
objJMail.Sender = Request.Form("YourEmail")
objJMail.SenderName = Request.Form("YourName")
objJMail.AddRecipient Request.Form("RecipEmail")
objJMail.Subject = "Look at this page from the www.TEST.org website"
objJMail.Body = strRecipName & "," & vbCrLf & vbCrLf & strYourName & " wants you to take a look at this page at www.TEST.org:" & vbCrLf & "Page Link: " & strURL & vbCrLf & vbCrLf & strComments
IF objJMail.Execute THEN

Set objJMail = Nothing

strYourName = request.form("YourName")
Response.Write strYourName
<p>Thank you for sharing this page with
strRecipName = request.form("RecipName")
Response.Write strRecipName
. Your message has been sent successfully and will be received by
strRecipName = request.form("RecipName")
Response.Write strRecipName

Response.Write "Sorry, there was an error and your email could not be sent at this time."

03-30-2006, 03:48 PM
In your HTML have 5 textfields.

In your script validate them to check that they are filled in and are valid email format.

You can then loop the email for each or join together the names to send as a BCC etc.