I am facing the same issue. Basically the getContent() method
returns ByteArrayInputStream instead of Multipart... Can someone
please help?
On Oct 23, 11:50 am, Kyle Roche k...@appirio.com wrote:
Hi,
I was able to put together an incoming email servlet that can read the
subject and the metadata. However, I have not been able to
successfully extract the body of the message. Can anyone post an
example? Here's what I have so far:
import java.io.IOException;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.*;
@SuppressWarnings(serial)
public class MailHandlerServlet extends HttpServlet {
public void doPost(HttpServletRequest req,
HttpServletResponse resp)
throws IOException {
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
try {
MimeMessage message = new MimeMessage(session,
req.getInputStream
());
Message emailMessage = new MimeMessage(session);
emailMessage.setFrom(new
InternetAddress(k...@gmail.com, from
address));
emailMessage.addRecipient(Message.RecipientType.TO,
new
InternetAddress(k...@gmail.com, to address));
emailMessage.setSubject(message.getSubject());
// HOW DO I GET THE MESSAGE?
emailMessage.setText(message);
Transport.send(emailMessage);
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---