Two Laptop Bag
The moose likes Other JSE/JEE APIs and the fly likes Hide All recipients email address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Hide All recipients email address" Watch "Hide All recipients email address" New topic

Hide All recipients email address

varun bihani
Ranch Hand

Joined: Aug 11, 2003
Posts: 96
I am able to send html format mail using javamail.
but I want to send mail to multiple users at the same time.
so i have stored email addresses in an array but i dont want to display all the email addresses on the TO field in the recipients mail box. I only want to that the reciepient see that the mail has been sent to him only..
My code goes something like this..
String to=request.getParameter("to");
String from=request.getParameter("from");
String subject=request.getParameter("subject");
String body=request.getParameter("body");
String mailHost="";
boolean sent = false;
Properties props = new Properties();
props.setProperty("", mailHost);
Session ssn = Session.getDefaultInstance(props);
Message msg = new MimeMessage(ssn);
int i=0;
StringTokenizer st = new StringTokenizer(to,",");
String[] totalrec=new String[10];
while (st.hasMoreTokens())
totalrec[i]= st.nextToken();
InternetAddress fromAdd = new InternetAddress(from);
InternetAddress[] toAdd = new InternetAddress[i];
for (int j = 0; j < i; j++)
toAdd[j] = new InternetAddress(totalrec[j]);
msg.setRecipients(Message.RecipientType.TO, toAdd);
msg.setContent(body, "text/html");
sent = true;

}catch(Exception e)

<a href="" target="_blank" rel="nofollow"></a><br /><a href="" target="_blank" rel="nofollow"></a><br /><a href="" target="_blank" rel="nofollow"></a>
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Perhaps you want to send the message to yourself and then BCC (blind carbon copy) each recipient. Take a look at the Message class and the Message.RecipientType class documentations.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
It is sorta covered in the JavaRanch Style Guide.
subject: Hide All recipients email address
It's not a secret anymore!