Email sending

Email sending

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.

View Answers

August 30, 2012 at 12:36 PM

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 = "[email protected]";
   String from = "[email protected]";
   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:

http://www.roseindia.net/javamail/

http://www.roseindia.net/mail/sending-an-email-in-jsp.shtml









Related Tutorials/Questions & Answers:
Email sending
Email sending  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
Sending email without authentication
Sending email without authentication  Hi sir, Am doing a project in JSP, in that i want to send mail without any authentication of password so send.../mail/sending-an-email-in-jsp.shtml
Advertisements
sending automatic email - JavaMail
sending automatic email  Dear sir. In my project i need to send an automatic email to the clients when their accounts are going to expire in 30 days.i am using jsp,mysql and tomcat for my project.Expire information are stored
Sending an email in JSP
Sending an email in JSP       Sending an email in JSP In this section, you will learn how to send an email in jsp.   Following is a simple JSP page for sending
sending email code - JSP-Servlet
sending email code  How To Send Emails using jsp  Hi friend, I am sending you a link. This link will help you. Please visit for more information. http://www.roseindia.net/mail/sending-an-email
code for sending email using j2me
code for sending email using j2me  could someone tell me why when i try to compile this line using netbeans 7.1 Properties property... for sending a file attachment to gmail account
Sending email with read and delivery requests
Sending email with read and delivery requests  Hi there, I am sending emails using JavaMail in Servlets on behalf of a customer from the website, and I'm having difficulty understanding how to implement, read and delivery
Email sending in jsp - JSP-Servlet
Email sending in jsp  Hi, Im trying to send email from my jsp... i've already tried a sample code from google, for sending email to my office 'smtp... attached the whole coding as below: For input :index.jsp Sending
automatically resend when connection lost in sending email
automatically resend when connection lost in sending email  send automatically email when connection lost in sending bulk email using javamail for exp more than 10000 emails
automatically resend when connection lost in sending email
automatically resend when connection lost in sending email  send automatically email when connection lost in sending bulk email using javamail for exp more than 10000 emails
automatically resend when connection lost in sending email
automatically resend when connection lost in sending email  send automatically email when connection lost in sending bulk email using javamail for exp more than 10000 emails
sending email using smtp in java
sending email using smtp in java  Hi all, I am trying to send and email to through my company mail server. Following is my code package com.tbss; import javax.mail.*; import javax.mail.internet.*; import
Email queue while sending mail using Struts Class
Email queue while sending mail using Struts Class  Can I maintain a queue of mails being sent from a JSP page in a DB to get its status
Email queue while sending mail using Struts Class
Email queue while sending mail using Struts Class  Can I maintain a queue of mails being sent from a JSP page in a DB to get its status
Same email-massage is sending twice in online server(tomcat) but working fine in my local server(Tomcat)..
Same email-massage is sending twice in online server(tomcat) but working fine in my local server(Tomcat)..  Sir, I created one project in jsp for a software company. I am using listeners and timer for sending automatic
PHP Email Tutorial, Sending email from PHP
Sending mail in PHP In this section we will learn how to send email from PHP program. You can send email from your PHP script using mail(...) function... call. Example 2. $email="[email protected], [email protected]
email
email   hi I am using 1and1 server. Using this server i am sending a mail using java program . But it is running some problem occur " Cannot send email. javax.mail.SendFailedException: Invalid Addresses;ADS_TO_REPLACE_1
email
email  how do i code for making clicking a send button sends a email
Sending emails and insert into trable
Sending emails and insert into trable  I have created a form, once people submit it should go to the email and insert to table also, the second part is working, but it's not getting to configured email. the code is below, I'm I
sending mail - JSP-Servlet
sending mail  Hi, what is the code for sending mail automatically without user intervention? thanks in advance
sending mails - JSP-Servlet
sending mails  my intension is sending mails through java program with out installing any softwares.what is code
Sending Email with Attachment
Sending Email with Attachment       This Example shows you how to send a Attachment in the message using... the Transport.send() method. By this code you can get functionality to send Email
iphone mail sending problem
iphone mail sending problem  Hi, I'm receiving the following error ... while sending mail in my iphone application Terminating app due to uncaught... an image to the email NSString *path = [[NSBundle mainBundle] pathForResource
sending mails - JSP-Servlet
sending mails   sending mail using smtp protocal ,while running,i got error an javax.mail.sendfailed exception. what is this error
sending emails - JavaMail
sending emails  what is the code for sending emails in java  Hi Friend, Please visit the following link: http://www.roseindia.net/javamail/ Hope that it will be helpful for you. Thanks
sending data to facebook
sending data to facebook  how to post data into facebook from a java program
sending mail using jsp
sending mail using jsp  please give me the detailed procedure and code for sending mail through jsp program   Please visit the following links: http://www.roseindia.net/ejb/introduction/j2eedemo.shtml http
Sending mail - JavaMail
Sending mail  Need a simple example of sending mail in Java  Hi,To send email you need a local mail server such as apache james. You first...) { to = newTo;}}Thanks  Java Code for sending messages(text or multimedia
Sending hidden values
Sending hidden values  how to send more than one hidden values through javascript function . Main purpose is to remove href link (Query string should not appear in url bar
Sending File - JSP-Servlet
Sending File  How to use tag in Jsp, & How read a file fom Client  Hi Friend, We used tag to upload a file. Please visit the following links: http://www.roseindia.net/jsp/fileupload.shtml http
sending sms from laptop to mobile
sending sms from laptop to mobile   sending sms from laptop to mobile for multi users
sending sms from laptop to mobile
sending sms from laptop to mobile   sending sms from laptop to mobile for multi users
sending a mail - JSP-Servlet
sending a mail   I m writing a code for send mail in jsp,i sending a mail to specified receiver but if i attach an file and send a mail then i m getting an error. Here Attachment is in String[] Attachment=null so how
for sending project build
for sending project build  hello I want to send my iphone project build to someone else how can i send it...   yes you can send butADS_TO_REPLACE_1 Follow the steps on the portal to creating an ad hoc build
Sending Emails In Java
Sending Emails In Java  I want to send emails from within a java program. I saw some online java programs to do that, but they needed me to enter a smtp server, but i don't know what that should be. Can someone please help
Sending Emails In Java
Sending Emails In Java  I want to send emails from within a java program. I saw some online java programs to do that, but they needed me to enter a smtp server, but i don't know what that should be. Can someone please help
Sending Emails In Java
Sending Emails In Java  I want to send emails from within a java program. I saw some online java programs to do that, but they needed me to enter a smtp server, but i don't know what that should be. Can someone please help
java mail sending with images
java mail sending with images  I need to send images through java mail without giving content path(i.e. we don't want hard code the image path)can you tell me the idea?   Please visit the following links: http
sending a zip file to servlet
sending a zip file to servlet  I have created a .zip file in a servlet on the local system(no static ip). The .zip file contains xml files. I have to send it to another servlet which is in a server(has a static ip). I have done
struts2 email code
struts2 email code  when I tried the code of sending email suggested by you on when I tried the code of sending email suggested by you on giving following exception. com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must
regarding sending mesage - JavaMail
regarding sending mesage  i have tried the following program /* import java.util.*; import javax.mail.*; import javax.mail.internet.*; import... me in this regard   Hi friend, I am sending you a link
ModuleNotFoundError: No module named 'sending_gmail'
ModuleNotFoundError: No module named 'sending_gmail'  Hi, My... 'sending_gmail' How to remove the ModuleNotFoundError: No module named 'sending_gmail' error? Thanks   Hi, In your python
sending commands through RxTx
sending commands through RxTx  i am trying to call lightOn and LightOff method from NewSerialWriter's run() method but not able to make the correct logic. please help me with this. here is my code of different classes. package
sending doc files - Swing AWT
sending doc files  how to send doc file using java from one machine to other over a network
Sending data using bluetooth in android
Sending data using bluetooth in android  code to send data between two android mobile devices using bluetooth
email archiving
email archiving  Hi, What is email archiving? Thanks
Send email as html with embedded images as background
Send email as html with embedded images as background  Hi, I am developing a PHP mailing application. I have to send image in the email as attachment. Give me solution for sending image in the email data. Thanks
sending sms with help of java - JavaMail
sending sms with help of java  hi can u plz help me to learn how to send sms with help of java. waiting for your reply
generate Email - JSP-Servlet
generate Email  Hi I need to generate an automated email and need to send it to the client like an confirmation email after registering to my website..., For solving the problem visit to : http://www.roseindia.net/mail/sending
email entire page javascript
email entire page javascript  How to email entire page in JavaScript...['purpose']) && $_GET['purpose'] == "email") { $message = ob_get_contents(); ob_end_clean(); // your code for sending the $message } else

Ads