List of usage examples for javax.mail.internet MimePart setContent
public void setContent(Object obj, String type) throws MessagingException;
From source file:org.sakaiproject.kernel.messaging.email.EmailMessageListener.java
/** * Sets the content of the mime part using the content of the email message. * * @param mimePart//from w w w .java 2s .co m * To where the content should be set. * @param email * From where the content should be retrieved. * @throws IOException * If the content is a URL and there is a problem opening a stream * to it. * @throws MessagingException * If there is a problem setting the content to the mime part. */ private void setContent(MimePart mimePart, Message email) throws IOException, MessagingException { Object content = null; if (email.isBodyText()) { content = email.getText(); } else { URL url = email.getBody(); URLConnection conn = url.openConnection(); content = conn.getContent(); } mimePart.setContent(content, email.getMimeType()); }