
Hi sir,
Am doing a project, in that i need to send email to multiple recipients at a same time using jsp so send me the code as soon as possible.
Regards, Santhosh.

Here is a jsp code that send mail to multiple recipients.
<%@ page import="java.io.*,java.util.*,javax.mail.*"%>
<%@ page import="javax.mail.internet.*,javax.activation.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%
String result;
String to = "abcd@gmail.com";
String from = "mcmohd@gmail.com";
String host = "localhost";
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", host);
Session mailSession = Session.getDefaultInstance(properties);
try{
MimeMessage message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress(from));
message.addRecipients(Message.RecipientType type, Address[] addresses);
message.setSubject("This is the Subject Line!");
message.setText("This is actual message");
Transport.send(message);
result = "Sent message successfully....";
}catch (MessagingException mex) {
mex.printStackTrace();
result = "Error: unable to send message....";
}
%>
<html>
<head>
<title>Send Email using JSP</title>
</head>
<body>
<center>
<h1>Send Email using JSP</h1>
</center>
<p align="center">
<%
out.println("Result: " + result + "\n");
%>
</p>
</body>
</html>
where addresses is the array of email ID. You would need to use InternetAddress() method while specifying email IDs
For more information, visit the following links:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.