System.out.println( "HTML = text/html : " + htmlPart.isMimeType( "text/html" ) ); System.out.println( "HTML Content Type: " + htmlPart.getContentType() ); System.out.println( "HTML Data Handler: " + htmlPart.getDataHandler().getContentType() );
/** * Return a decoded input stream for this body part's "content". <p> * * This implementation obtains the input stream from the DataHandler. * That is, it invokes getDataHandler().getInputStream(); * * @return an InputStream * @exception IOException this is typically thrown by the * DataHandler. Refer to the documentation for * javax.activation.DataHandler for more details. * @exception MessagingException for other failures * * @see #getContentStream * @see javax.activation.DataHandler#getInputStream */ public InputStream getInputStream() throws IOException, MessagingException { return getDataHandler().getInputStream(); }
/** * Return a decoded input stream for this body part's "content". <p> * * This implementation obtains the input stream from the DataHandler. * That is, it invokes getDataHandler().getInputStream(); * * @return an InputStream * @exception IOException this is typically thrown by the * DataHandler. Refer to the documentation for * javax.activation.DataHandler for more details. * @exception MessagingException for other failures * * @see #getContentStream * @see javax.activation.DataHandler#getInputStream */ @Override public InputStream getInputStream() throws IOException, MessagingException { return getDataHandler().getInputStream(); }
@Test void testTextHtml() throws MessagingException, IOException { final Email email = Email.create() .from(FROM_EXAMPLE_COM) .to(TO_EXAMPLE_COM) .subject(SUB) .textMessage(HELLO) .htmlMessage("<html><body><h1>Hey!</h1></body></html>"); final Message message = createMessage(email); assertEquals(1, message.getFrom().length); assertEquals(FROM_EXAMPLE_COM, message.getFrom()[0].toString()); assertEquals(1, message.getRecipients(RecipientType.TO).length); assertEquals(TO_EXAMPLE_COM, message.getRecipients(RecipientType.TO)[0].toString()); assertEquals(SUB, message.getSubject()); // wrapper final MimeMultipart multipart = (MimeMultipart) message.getContent(); assertEquals(1, multipart.getCount()); assertTrue(multipart.getContentType().contains("multipart/mixed")); // inner content final MimeBodyPart mimeBodyPart = (MimeBodyPart) multipart.getBodyPart(0); final MimeMultipart mimeMultipart = (MimeMultipart) mimeBodyPart.getContent(); assertEquals(2, mimeMultipart.getCount()); assertTrue(mimeMultipart.getContentType().contains("multipart/alternative")); MimeBodyPart bodyPart = (MimeBodyPart) mimeMultipart.getBodyPart(0); assertEquals(HELLO, bodyPart.getContent()); assertTrue(bodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_PLAIN)); bodyPart = (MimeBodyPart) mimeMultipart.getBodyPart(1); assertEquals("<html><body><h1>Hey!</h1></body></html>", bodyPart.getContent()); assertTrue(bodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_HTML)); }
assertTrue(htmlMimeBodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_HTML)); DataSource dataSource = htmlMimeBodyPart.getDataHandler().getDataSource(); assertEquals(IMAGE_PNG, dataSource.getContentType()); assertArrayEquals(BYTES_1_7, read(dataSource)); dataSource = mimeBodyPart.getDataHandler().getDataSource(); assertEquals(APPLICATION_ZIP, dataSource.getContentType()); assertArrayEquals(BYTES_11_15, read(dataSource));
public synchronized DataHandler getDataHandler() throws MessagingException { if (dh == null) { if (bs.isMulti()) dh = new DataHandler( new IMAPMultipartDataSource( this, bs.bodies, sectionId, message) ); else if (bs.isNested() && message.isREV1() && bs.envelope != null) dh = new DataHandler( new IMAPNestedMessage(message, bs.bodies[0], bs.envelope, sectionId), type ); } return super.getDataHandler(); }
@Override public synchronized DataHandler getDataHandler() throws MessagingException { if (dh == null) { if (bs.isMulti()) dh = new DataHandler( new IMAPMultipartDataSource( this, bs.bodies, sectionId, message) ); else if (bs.isNested() && message.isREV1() && bs.envelope != null) dh = new DataHandler( new IMAPNestedMessage(message, bs.bodies[0], bs.envelope, sectionId), type ); } return super.getDataHandler(); }
Object c; try { c = getDataHandler().getContent(); } catch (FolderClosedIOException fex) { throw new FolderClosedException(fex.getFolder(), fex.getMessage());
Object c; try { c = getDataHandler().getContent(); } catch (FolderClosedIOException fex) { throw new FolderClosedException(fex.getFolder(), fex.getMessage());
public Object getContent() throws MessagingException, IOException { return getDataHandler().getContent(); }
public static MimeMultipart createMimeMultipart(MimeBodyPart bodypart) throws MessagingException { return new MimeMultipart(bodypart.getDataHandler().getDataSource()); }
public InputStream getInputStream() throws MessagingException, IOException { return getDataHandler().getInputStream(); }
public InputStream getInputStream() throws MessagingException, IOException { return getDataHandler().getInputStream(); }
public Object getContent() throws MessagingException, IOException { return getDataHandler().getContent(); }
/** * Return a decoded input stream for this body part's "content". <p> * * This implementation obtains the input stream from the DataHandler. * That is, it invokes getDataHandler().getInputStream(); * * @return an InputStream * @exception IOException this is typically thrown by the * DataHandler. Refer to the documentation for * javax.activation.DataHandler for more details. * @exception MessagingException for other failures * * @see #getContentStream * @see javax.activation.DataHandler#getInputStream */ @Override public InputStream getInputStream() throws IOException, MessagingException { return getDataHandler().getInputStream(); }
public void writeTo(OutputStream out) throws IOException, MessagingException { headers.writeTo(out, null); // add the separater between the headers and the data portion. out.write('\r'); out.write('\n'); // we need to process this using the transfer encoding type OutputStream encodingStream = MimeUtility.encode(out, getEncoding()); getDataHandler().writeTo(encodingStream); encodingStream.flush(); }
public void writeTo(OutputStream out) throws IOException, MessagingException { headers.writeTo(out, null); // add the separater between the headers and the data portion. out.write('\r'); out.write('\n'); // we need to process this using the transfer encoding type OutputStream encodingStream = MimeUtility.encode(out, getEncoding()); getDataHandler().writeTo(encodingStream); encodingStream.flush(); }
private void initMultipart(MimeMultipart multipart) throws MessagingException { this.mimeMP = multipart; MimeBodyPart part = (MimeBodyPart) multipart.getBodyPart(0); setSoapMessage(new SimpleAttachment(part.getContentID(), part.getDataHandler())); for ( int i = 1; i < multipart.getCount(); i++ ) { part = (MimeBodyPart) multipart.getBodyPart(i); String id = part.getContentID(); if (id.startsWith("<")) { id = id.substring(1, id.length() - 1); } addPart(new SimpleAttachment(id, part.getDataHandler())); } }
public synchronized DataHandler getDataHandler() throws MessagingException { if (dh == null) { if (bs.isMulti()) dh = new DataHandler( new IMAPMultipartDataSource( this, bs.bodies, sectionId, message) ); else if (bs.isNested() && message.isREV1() && bs.envelope != null) dh = new DataHandler( new IMAPNestedMessage(message, bs.bodies[0], bs.envelope, sectionId), type ); } return super.getDataHandler(); }
public synchronized DataHandler getDataHandler() throws MessagingException { if (dh == null) { if (bs.isMulti()) dh = new DataHandler( new IMAPMultipartDataSource( this, bs.bodies, sectionId, message) ); else if (bs.isNested() && message.isREV1()) dh = new DataHandler( new IMAPNestedMessage(message, bs.bodies[0], bs.envelope, sectionId), type ); } return super.getDataHandler(); }