// Get a mail session
Session session1 = Session.getDefaultInstance(props, null);
String from = "firstname.lastname@example.org";
String to = "email@example.com";
// Define a new mail message
Message message = new MimeMessage(session1);
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
// Create a message part to represent the body text
BodyPart messageBodyPart = new MimeBodyPart();
// Get the generated email from the request attribute
String emailStuff = (String)request.getAttribute("test");
Joined: Aug 26, 2009
I remember implementing this for one of my projects.
There is a custom tag available using which you can store the output of the JSP (i.e. HTML page) in a HttpSession attribute. I dont remember the name but you can google for the same.
You can then retrieve the contents of the HttpSession attribute and then add it as a content or as attachment.
Joined: Mar 22, 2005
I think it would be much simpler to just send the URL of the web page the user is looking at. Many people are unwilling to receive HTML content, or even have email clients that are unable to do so. And even if both are not the case, it'll be very tricky to obtain decent results (e.g., many email clients block images in HTML emails).