Solved

sending multiple mail recepiants via form to a JSP

Posted on 2004-03-28
5
248 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running Java Servlet inside Eclipse Luna 6 148
rebasing and merging used in SCM 1 66
constructor overloading 2 79
how to add new optional parameter to JSP 1 29
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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

26 Experts available now in Live!

Get 1:1 Help Now