Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet Email sending in jsp
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Jaya Krishnan
Email sending in jsp
1 Answer(s)      5 years and 10 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

December 4, 2008 at 1:25 AM


Hi friend,

Code to solve the problem :

"mailAPI.jsp"

<html>
<head>
<title>Mail API</title>
</head>

<body>

<table border="1" width="50%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%">
<form method="POST" action="mail.jsp">
<table border="1" width="100%" cellpadding="0" cellspacing="0">
<h1>Mail API</h1>
<tr>
<td width="50%"><b>To:</b></td>
<td width="50%"><input type="text" name="to" size="30"></td>
</tr>
<tr>
<td width="50%"><b>From:</b></td>
<td width="50%"><input type="text" name="from" size="30"></td>
</tr>
<tr>
<td width="50%"><b>Subject:</b></td>
<td width="50%"><input type="text" name="subject" size="30"></td>
</tr>
<tr>
<td width="50%"><b>Description:</b></td>
<td width="50%"><textarea name="description" type="text"
cols="40" rows="15" size=100>
</textarea>
</td>
</tr>
<tr>
<td><p><input type="submit" value="Send Mail" name="sendMail"></td>
</tr>
</table>
</p>
</form>
</td>
</tr>
</table>
</body>

</html>

"mail.jsp"

<%@ page language="java" import="javax.naming.*,java.io.*,javax.mail.*,
javax.mail.internet.*,com.sun.mail.smtp.*"%>

<html>
<head>
<title>Mail</title>
</head>

<body>

<%
try{
Session mailSession = Session.getInstance(System.getProperties());
Transport transport = new SMTPTransport(mailSession,new URLName("localhost"));
transport.connect("localhost",25,null,null);


MimeMessage m = new MimeMessage(mailSession);
m.setFrom(new InternetAddress(%><%request.getParameter("from")%><%));
Address[] toAddr = new InternetAddress[] {
new InternetAddress(%><%request.getParameter("to")%><%)
};
m.setRecipients(javax.mail.Message.RecipientType.TO, toAddr );
m.setSubject(%><%request.getParameter("subject")%><%);
m.setSentDate(new java.util.Date());
m.setContent(%><%request.getParameter("description")%><%, "text/plain");
transport.sendMessage(m,m.getAllRecipients());
transport.close();
out.println("Thanks for sending mail!");
}
catch(Exception e){

out.println(e.getMessage());
e.printStackTrace();
}
%>


</body>

</html>

For more information on Java Mail Api visit to :

http://roseindia.net/javamail/

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

Thanks


Related Tutorials/Questions & Answers:
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
Email sending in jsp - JSP-Servlet
Email sending in jsp  Hi, Im trying to send email from my jsp webserver.My webpage is running on Tomcat 5.0 server, and im using jsp coding.Now i've already tried a sample code from google, for sending email to my office 'smtp
Advertisements
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
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
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 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..., Gareth   Please visit the following link: JSP Servlet Send Mail
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 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
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
JSP Email
JSP Email  Hi, How to send email using JSP? Thanks   Hi, Check this tutorial: Send Email to selected dropdown user Thanks
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
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. I m using jsp code. Please help me out with this issue.  Hi friend
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 File - JSP-Servlet
Sending File  How to use tag in Jsp, & How read a file fom... the following links: http://www.roseindia.net/jsp/fileupload.shtml http://www.roseindia.net/jsp/upload-insert-csv.shtml Hope that it will be helpful for you
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...... Attach : //In jsp... String strFileAttachment = request.getParameter
sending mails - JSP-Servlet
sending mails  my intension is sending mails through java program with out installing any softwares.what is code
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   sending mail using smtp protocal ,while running,i got error an javax.mail.sendfailed exception. what is this error
jsp email - JSP-Servlet
jsp email  when the user forgets his password how to enable the user to retrieve his password using jsp code
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
send HTML Email with jsp and servlet
send HTML Email with jsp and servlet  Can You please show me how to send html Email using JSP and Servlet thank you
how to display the email message in jsp
how to display the email message in jsp  hi every one .. i am new from this industry please help me to display the email message in jsp page please send me sample code
Email to multiple recipients using jsp
Email to multiple recipients using jsp  Hi sir, Am a doing a project,in that i need to send email to multiple user at a time,the to address should enter manually its not not be written in code using jsp. Regards, Santhosh
Email to multiple recipients using jsp
Email to multiple recipients using jsp  Hi sir, Am a doing a project,in that i need to send email to multiple user at a time,the to address should enter manually its not not be written in code using jsp. Regards, Santhosh
sending mail with attachment in jsp - JSP-Servlet
sending mail with attachment in jsp  Hi, Can any one pls tell me how to send email with attachment in jsp. I know how to send mail without attachment but with attachment its not working for me. If u hve any idea please
Sending query with variable - JSP-Servlet
Sending query with variable   While displaying pages in frames concept, one page contains links and other page contains messages for that links. The links page is not static one. Links page displays the contents from
Validate email id in jsp - JSP-Interview Questions
Validate email id in jsp  Hi Please Suggest me how to validate email id in JSP(Java Server Faces
Advertisements
 

 

 

DMCA.com