permaculture playing cards*
The moose likes JSP and the fly likes Email in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Email in jsp" Watch "Email in jsp" New topic
Author

Email in jsp

suman vasireddy
Greenhorn

Joined: Nov 17, 2008
Posts: 12
hey guys im able to create email gui with JSP but im facing problems with sending email.....please help me out......

thanks in advance....
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
Suman wrote:
hey guys im able to create email gui with JSP but im facing problems with sending email.....please help me out......


Hi Suman,
Welcome to java ranch
Can you specify the exact problems you are facing with sending mails?
[ November 17, 2008: Message edited by: Amol Nayak ]
suman vasireddy
Greenhorn

Joined: Nov 17, 2008
Posts: 12
<html>
<head>
<title>JSP JavaMail Example </title>
</head>

<body>

<%@ page import="java.util.*" %>
<%@ page import="javax.mail.*" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="javax.activation.*" %>

<%
String host = "yourmailhost";
String to = request.getParameter("to");
String from = request.getParameter("from");
String subject = request.getParameter("subject");
String messageText = request.getParameter("body");
boolean sessionDebug = false;

Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");

Session mailSession = Session.getDefaultInstance(props, null);

mailSession.setDebug(sessionDebug);

Message msg = new MimeMessage(mailSession);

msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);

Transport.send(msg);

out.println("Mail was sent to " + to);
out.println(" from " + from);
out.println(" using host " + host + ".");

%>
</table>
</body>
</html>
this is my code and im unable to run this pease solve my problem...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Email in jsp
 
Similar Threads
problem with struts1.1 please help me...
connecting jsp page with sql
memo application
JSP to hibernate
want to generate html formatted email that supports outlook?