Solved

sending multiple mail recepiants via form to a JSP

Posted on 2004-03-28
5
253 Views
Last Modified: 2010-04-01
I found that if I were to use a simple thing as mailto to a list of user in a String format. i.e.

<% String finalEmailList = "user1@company.com,user2@company.com"; %>
<a href="mailto:<%=finalEmailList%>">Email candidate</a>

Groupwise does not really like it and only sent email to the first user. Any clue on how to solve this?

I have since created a form post thing...but still stuck. I am not sure if I need to introduce Array. If I need to, how could I get the email into array and then pass it via form post?

Any help is much appreciated. Thank you.


[CODE]
<%
String finalEmailList = "user1@company.com,user2@company.com";
%>

<FORM name=myform METHOD="post" ACTION="sendMail.jsp">

<INPUT class=inputText TYPE="text" NAME="f_mail_subject" MAXLENGTH="200" SIZE="40" VALUE="">

<TEXTAREA NAME="f_mail_body" COLS=40 ROWS=8 VALUE=""></TEXTAREA>

<input type="hidden" name="f_mail_to" value="<%=finalEmailList%>" >
<input class="buttons" type="submit" value="submit" name="action">
<input class="buttons" type="Reset">

</form>

---- This is my sendMail.jsp ---

<%@ page import="com.mail.SendMail"%>
<%@ page import="com.mail.AppConfig"%>
<% AppConfig appConfig = new AppConfig(); %>

SendMail thisSendMail = new SendMail();
               
thisSendMail.setUser(appConfig.getMailUser());
thisSendMail.setPwd(appConfig.getMailPwd());      
thisSendMail.setServer(appConfig.getSmtpServer());
thisSendMail.setFrom(appConfig.getSystemAccount());
thisSendMail.setTo(request.getParameter("f_mail_to"));
thisSendMail.setContentType("text/html");
thisSendMail.setSubject(request.getParameter("f_mail_subject"));
thisSendMail.setMessage(request.getParameter("f_mail_body"));
               
if ( thisSendMail.Send() )
{
   out.println(" Mail sent successful.");
} else {
   out.println("unsuccessful");
}
[/CODE]
0
Comment
Question by:Tuan_Jean
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
searlas earned 20 total points
ID: 10702636
1) See the mailto: url spec (you may want to use cc and bcc lines to handle multiple addresses)
http://www.faqs.org/rfcs/rfc2368.html

2) You cannot use a form to post to or launch your mail reader (Groupwise.)
0
 
LVL 7

Expert Comment

by:searlas
ID: 10702665
Correction, to (2) above...

Yes, you can... but you/I get a warning when doing it:
Use ; instead of , to separate mail addresses...

<html>
    <head>
        <title>email test</title>
    </head>
    <body>
        <form action="mailto:sampe@spam.com;sample2@spam.com" method="get">
            <input type="text" name="subject">
            <input type="submit" value="go">
        </form>
    </body>
</html>
0
 

Author Comment

by:Tuan_Jean
ID: 10720181
I found that I could use message.addRecepiant
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
unit test DAO layer 1 148
java beans and EJBs 5 203
error when compiling my project in eclipse luna 30 538
countXY challenge 28 179
Changing a few Outlook Options can help keep you organized!
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question