...

View Full Version : Email to multiple addresses with JMail in ASP



anessa05
05-05-2006, 05:15 PM
Hello!
How would you edit the following code to enable the user to enter multiple email recipients, separated by commas into a single html text field? This "email this article to a friend" form currently only allows the user to email one person. I'm using JMail in ASP.



<% If (Request.Form("requiredemail") = "") Then %>
<FORM METHOD="POST">
<p>Email address to send game link to<br>
<input type="text" name="requiredemail" size="40" maxlength="128"></input>
<p>Message<br>
<textarea name="message" cols="35" rows="4">test</textarea>
<input type="submit" class="hdindex" value="send"></input>
</form>

<%Else
requiredemailto = Request.Form("requiredemail")
message = Request.Form("message")

strBody = "Link to survey" & chr(10) & chr(10) & _

"Email Address: " & requiredemail & chr(10) & _
"Message: " & message & chr(10)
%>

<%
set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.ServerAddress = "REMOVED FOR POSTING"
JMail.Sender = "webmaster@test.org"
JMail.SenderName = "test.org"
'Who the e-mail is sent to
JMail.AddRecipient Request.Form("requiredEmail")
JMail.Subject = "Link to article"
JMail.Body = Request.Form("message")
JMail.Execute
%>

Spudhead
05-08-2006, 02:26 PM
enter multiple email recipients, separated by commas into a single html text field

I don't want to give too much away, but I'd strongly recommend that you look into the VBScript split() function, possibly the trim() function and, following that, into looping through arrays.

:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum