Java Code Examples for javax.mail.internet.MimeMessage#getLineCount()
The following examples show how to use
javax.mail.internet.MimeMessage#getLineCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MimeMessageTest.java From james-project with Apache License 2.0 | 5 votes |
@Test public void testGetLineCount() throws Exception { MimeMessage mm = getMissingEncodingMessage(); try { int count = mm.getLineCount(); assertThat(count == -1 || count == 7).isTrue(); } catch (Exception e) { fail("Unexpected exception in getLineCount"); } LifecycleUtil.dispose(mm); }
Example 2
Source File: NotifyMailetsMessage.java From james-project with Apache License 2.0 | 4 votes |
public String generateMessage(String parameterMessage, Mail originalMail) throws MessagingException { MimeMessage message = originalMail.getMessage(); StringBuilder builder = new StringBuilder(); builder.append(parameterMessage).append(LINE_BREAK); if (originalMail.getErrorMessage() != null) { builder.append(LINE_BREAK) .append("Error message below:") .append(LINE_BREAK) .append(originalMail.getErrorMessage()) .append(LINE_BREAK); } builder.append(LINE_BREAK) .append("Message details:") .append(LINE_BREAK); if (message.getSubject() != null) { builder.append(" Subject: ") .append(safelyDecode(message.getSubject())) .append(LINE_BREAK); } if (message.getSentDate() != null) { builder.append(" Sent date: " + message.getSentDate()) .append(LINE_BREAK); } builder.append(" MAIL FROM: " + originalMail.getMaybeSender().asString()) .append(LINE_BREAK); boolean firstRecipient = true; for (MailAddress recipient : originalMail.getRecipients()) { if (firstRecipient) { builder.append(" RCPT TO: " + recipient) .append(LINE_BREAK); firstRecipient = false; } else { builder.append(" " + recipient) .append(LINE_BREAK); } } appendAddresses(builder, "From", message.getHeader(RFC2822Headers.FROM)); appendAddresses(builder, "To", message.getHeader(RFC2822Headers.TO)); appendAddresses(builder, "CC", message.getHeader(RFC2822Headers.CC)); getMessageSizeEstimation(originalMail).ifPresent(size -> builder .append(" Size: ") .append(SizeUtils.humanReadableSize(size)) .append(LINE_BREAK)); if (message.getLineCount() >= 0) { builder.append(" Number of lines: " + message.getLineCount()) .append(LINE_BREAK); } return builder.toString(); }