I saw a post about CVS attachment in mail yesterday. I make a similar
code to attach PDF file in email. However it doesn't work and no email
is sent out from JAE. Could anyone help to figure out how to make it
work?
//download PDF file
InputStream is = httpConn.getInputStream();
String content_type = httpConn.getContentType();
if(content_type.equalsIgnoreCase("application/pdf")) {
StringBuilder strBuild = new StringBuilder();
int read = -1;
byte[] buffer = new byte[4096];
while((read=is.read(buffer))!=-1){
strBuild.append(buffer.toString());
}
String pdf=strBuild.toString();
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
try {
Message msg = new MimeMessage(session);
msg.setDataHandler(new DataHandler(new
ByteArrayDataSource(pdf.getBytes(),"application/pdf")));
msg.setFileName("data.pdf");
msg.setFrom(new InternetAddress("...", "..."));
msg.addRecipient(Message.RecipientType.TO, new
InternetAddress("...", "..."));
msg.setSubject("...");
Transport.send(msg);
} catch ....
}
Thanks a lot
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.