@Test @Ignore public void testGetText() throws JavaMailerException, MessagingException, IOException { JavaReadMailer rm = createGoogleReadMailer(getUser(), getPassword()); List<Message> msgs = rm.retrieveMessages(); for (Message msg : msgs) { JavaReadMailer.getText(msg); JavaReadMailer.string2Lines("abc\nxyz"); } }
public static List<String> getText(Message msg) throws MessagingException, IOException { Object content = null; String text = null; log().debug("getText: getting text of message from MimeType: text/*"); try { text = (String)msg.getContent(); } catch (ClassCastException cce) { content = msg.getContent(); if (content instanceof MimeMultipart) { log().debug("getText: content is MimeMultipart, checking for text from each part..."); for (int cnt = 0; cnt < ((MimeMultipart)content).getCount(); cnt++) { BodyPart bp = ((MimeMultipart)content).getBodyPart(cnt); if (bp.isMimeType("text/*")) { text = (String)bp.getContent(); log().debug("getText: found text MIME type: "+text); break; } } log().debug("getText: did not find text within MimeMultipart message."); } } return string2Lines(text); }
JavaReadMailer extends JavaMailer2 { public static List<String> getText(Message msg) throws MessagingException, IOException { Object content = null; String text = null; log().debug("getText: getting text of message from MimeType: text/*"); try { text = (String)msg.getContent(); } catch (ClassCastException cce) { content = msg.getContent(); if (content instanceof MimeMultipart) { log().debug("getText: content is MimeMultipart, checking for text from each part..."); for (int cnt = 0; cnt < ((MimeMultipart)content).getCount(); cnt++) { BodyPart bp = ((MimeMultipart)content).getBodyPart(cnt); if (bp.isMimeType("text/*")) { text = (String)bp.getContent(); log().debug("getText: found text MIME type: "+text); break; } } log().debug("getText: did not find text within MimeMultipart message."); } } return string2Lines(text); } }
JavaReadMailer extends JavaMailer2 { public static List<String> getText(Message msg) throws MessagingException, IOException { Object content = null; String text = null; log().debug("getText: getting text of message from MimeType: text/*"); try { text = (String)msg.getContent(); } catch (ClassCastException cce) { content = msg.getContent(); if (content instanceof MimeMultipart) { log().debug("getText: content is MimeMultipart, checking for text from each part..."); for (int cnt = 0; cnt < ((MimeMultipart)content).getCount(); cnt++) { BodyPart bp = ((MimeMultipart)content).getBodyPart(cnt); if (bp.isMimeType("text/*")) { text = (String)bp.getContent(); log().debug("getText: found text MIME type: "+text); break; } } log().debug("getText: did not find text within MimeMultipart message."); } } return string2Lines(text); } JavaReadMailer(final ReadmailConfig config, Boolean closeOnDelete); }
JavaReadMailer extends JavaMailer2 { public static List<String> getText(Message msg) throws MessagingException, IOException { Object content = null; String text = null; log().debug("getText: getting text of message from MimeType: text/*"); try { text = (String)msg.getContent(); } catch (ClassCastException cce) { content = msg.getContent(); if (content instanceof MimeMultipart) { log().debug("getText: content is MimeMultipart, checking for text from each part..."); for (int cnt = 0; cnt < ((MimeMultipart)content).getCount(); cnt++) { BodyPart bp = ((MimeMultipart)content).getBodyPart(cnt); if (bp.isMimeType("text/*")) { text = (String)bp.getContent(); log().debug("getText: found text MIME type: "+text); break; } } log().debug("getText: did not find text within MimeMultipart message."); } } return string2Lines(text); } JavaReadMailer(final ReadmailConfig config, Boolean closeOnDelete); List<Message> retrieveMessages(); List<Message> retrieveMessages(SearchTerm term); List<Message> getMessages(); static List<String> getText(Message msg); Boolean isDeleteOnClose(); void setDeleteOnClose(Boolean deleteOnClose); static List<String> string2Lines(String text); }
JavaReadMailer extends JavaMailer2 { public static List<String> getText(Message msg) throws MessagingException, IOException { Object content = null; String text = null; log().debug("getText: getting text of message from MimeType: text/*"); try { text = (String)msg.getContent(); } catch (ClassCastException cce) { content = msg.getContent(); if (content instanceof MimeMultipart) { log().debug("getText: content is MimeMultipart, checking for text from each part..."); for (int cnt = 0; cnt < ((MimeMultipart)content).getCount(); cnt++) { BodyPart bp = ((MimeMultipart)content).getBodyPart(cnt); if (bp.isMimeType("text/*")) { text = (String)bp.getContent(); log().debug("getText: found text MIME type: "+text); break; } } log().debug("getText: did not find text within MimeMultipart message."); } } return string2Lines(text); } JavaReadMailer(final ReadmailConfig config, Boolean closeOnDelete); List<Message> retrieveMessages(); List<Message> retrieveMessages(SearchTerm term); List<Message> getMessages(); static List<String> getText(Message msg); Boolean isDeleteOnClose(); void setDeleteOnClose(Boolean deleteOnClose); static List<String> string2Lines(String text);  }