Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress("email@example.com"); msg.setReceipent(new InternetAddress("firstname.lastname@example.org"); msg.setSubject("A saying"); msg.setContent("Be careful what you wish for, you might get it"); Transport.send(msg);
I need to add 37 receipents to my receipents' list. What can you advice to me to make it faster? Maybe by creating a session object for each receipent and letting it run into a separate thread. Any suggestions? Thank you very much!
Instead of using setRecipient, you can use addRecipients to add as many as you need. If you want to send out multiple emails (one to each recipient), simply iterate the code you have, settting a new recipient each time. There's no need to start a new session for each email.
what did you try ? why do you think you need/can make it faster ?
did you have a look at the public void addRecipient(Message.RecipientType type,Address address) method in Message ? you can add all the recipients at once (of course only if they all receive the same email)