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("[email protected]", "from
address"));
emailMessage.addRecipient(Message.RecipientType.TO, new
InternetAddress("[email protected]", "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 [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-java?hl=en
-~----------~----~----~----~------~----~------~--~---