Solved

sending multiple mail recepiants via form to a JSP

Posted on 2004-03-28
5
247 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
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
searlas earned 20 total points
Comment Utility
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
Comment Utility
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
Comment Utility
I found that I could use message.addRecepiant
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
A procedure for exporting installed hotfix details of remote computers using powershell
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now