How to send javamail to a group
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, May 4, 2004 07:17 AM

Hello, I use the code above for sending email using java. Now I want to send my mail to a group, not only one mail adress, I mean I want to give an email list as an TO LIST, (but not one by one...One by one sending takes too much time.) How can I send a group mail? Thanks. *********************************************** public static void main(String args[]) { try { // Set the parameters String host ="mail.host.smtp"; String from = "from@com" ; String to ="to@com"; String subject = "msg. 1 from java!"; String message = "Message Goes Here!"; // The code to send mail Properties prop =System.getProperties(); //Return   More>>

Hello, I use the code above for sending email using java. Now I want to send my mail to a group, not only one mail adress, I mean I want to give an email list as an TO LIST, (but not one by one...One by one sending takes too much time.) How can I send a group mail? Thanks. ***********************************************
public static void main(String args[])
{
try
{
// Set the parameters
String host ="mail.host.smtp";
String from = "from@com" ;
String to ="to@com";
String subject = "msg. 1 from java!";
String message = "Message Goes Here!";
// The code to send mail
Properties prop =System.getProperties();
//Returns a properties objects containing the current
system properties.
prop.put("mail.smtp.host", host);
String lineSep = System.getProperty("line.separator"); Session ses = Session.getDefaultInstance(prop,null); MimeMessage msg = new MimeMessage(ses);
msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); msg.setSubject(subject);
msg.setText(message);
Transport.send(msg);
}

catch(javax.mail.internet.AddressException ae)
{ ae.printStackTrace();
}
catch(javax.mail.MessagingException me)
{
me.printStackTrace();
}
}

   <<Less

Re: How to send javamail to a group

Posted By:   Simon_Ablett  
Posted On:   Wednesday, May 5, 2004 04:23 AM

If your server recognises mailgroups you could define one there and then set that group as your target address in your client. Alternatively, define a group in a config file and read this in to your mail client, parse the group and add each component as a seperate target.

Regards.

Re: How to send javamail to a group

Posted By:   Simon_Ablett  
Posted On:   Tuesday, May 4, 2004 07:42 AM

Why have you posted this question twice with slightly different subject lines 'How to send javamail to a group' and 'send javamail to a group'? You won't get a faster response.

Regards.
About | Sitemap | Contact