use of com.fsck.k9.mail.internet.MimeMessage in project k-9 by k9mail.
the class MessageTest method sampleMessage.
private MimeMessage sampleMessage() throws MessagingException, IOException {
MimeMessage message = new MimeMessage();
message.setFrom(new Address("from@example.com"));
message.setRecipient(RecipientType.TO, new Address("to@example.com"));
message.setSubject("Test Message");
message.setHeader("Date", "Wed, 28 Aug 2013 08:51:09 -0400");
message.setEncoding(MimeUtil.ENC_7BIT);
MimeMultipart multipartBody = new MimeMultipart("multipart/mixed", generateBoundary());
multipartBody.addBodyPart(textBodyPart());
multipartBody.addBodyPart(binaryBodyPart());
MimeMessageHelper.setBody(message, multipartBody);
return message;
}
use of com.fsck.k9.mail.internet.MimeMessage in project k-9 by k9mail.
the class MessageTest method nestedMessage.
private MimeMessage nestedMessage(MimeMessage subMessage) throws MessagingException, IOException {
BinaryTempFileMessageBody tempMessageBody = new BinaryTempFileMessageBody(MimeUtil.ENC_8BIT);
OutputStream out = tempMessageBody.getOutputStream();
try {
subMessage.writeTo(out);
} finally {
out.close();
}
MimeBodyPart bodyPart = new MimeBodyPart(tempMessageBody, "message/rfc822");
bodyPart.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment");
bodyPart.setEncoding(MimeUtil.ENC_7BIT);
MimeMessage parentMessage = sampleMessage();
((Multipart) parentMessage.getBody()).addBodyPart(bodyPart);
return parentMessage;
}
use of com.fsck.k9.mail.internet.MimeMessage in project k-9 by k9mail.
the class MessageIdGeneratorTest method generateMessageId_withoutRelevantHeaders.
@Test
public void generateMessageId_withoutRelevantHeaders() throws Exception {
Message message = new MimeMessage();
String result = messageIdGenerator.generateMessageId(message);
assertEquals("<00000000-0000-4000-0000-000000000000@email.android.com>", result);
}
use of com.fsck.k9.mail.internet.MimeMessage in project k-9 by k9mail.
the class MessageIdGeneratorTest method generateMessageId_withFromAndReplyToAddress.
@Test
public void generateMessageId_withFromAndReplyToAddress() throws Exception {
Message message = new MimeMessage();
message.setFrom(new Address("alice@example.org"));
message.setReplyTo(Address.parse("bob@example.com"));
String result = messageIdGenerator.generateMessageId(message);
assertEquals("<00000000-0000-4000-0000-000000000000@example.org>", result);
}
use of com.fsck.k9.mail.internet.MimeMessage in project k-9 by k9mail.
the class MimeMessageParseTest method checkLeafParts.
private static void checkLeafParts(MimeMessage msg, String... expectedParts) throws Exception {
List<String> actual = new ArrayList<String>();
for (Body leaf : getLeafParts(msg.getBody())) {
actual.add(streamToString(MimeUtility.decodeBody(leaf)));
}
assertEquals(Arrays.asList(expectedParts), actual);
}
Aggregations