I need to send a jsp page as an attachment in mail.
I am using this part in code....
But using this I am getting the entire html script in the sent mail...
Can anybody help me out...??
Properties props = System.getProperties();
String mailServer = "mail.abc.com";
props.put("mail.smtp.host", mailServer);
Logger logger = Logger.getLogger(PropertyDashboardAction.class);
// Get a mail session
Session session1 = Session.getDefaultInstance(props, null);
String from = "
[email protected]";
String to = "
[email protected]";
// Define a new mail message
Message message = new MimeMessage(session1);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Test mail");
// Create a message part to represent the body text
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(emailStuff);
//use a MimeMultipart as we need to handle the file attachments
Multipart multipart = new MimeMultipart();
//add the message body to the mime message
multipart.addBodyPart(messageBodyPart);
// add any file attachments to the message
//addAtachments(attachments, multipart);
// Put all message parts in the message
message.setContent(multipart);
// Send the message
Transport.send(message);