Search in sources :

Example 1 with EmailAttachmentList

use of com.helger.smtp.data.EmailAttachmentList in project ph-web by phax.

the class FailedMailDataTest method _createEmailData.

@Nonnull
private static EmailData _createEmailData() {
    final EmailData aData = new EmailData(EEmailType.TEXT);
    aData.setFrom(new EmailAddress("from@example.org"));
    aData.replyTo().addAll(new EmailAddress("replyto1@example.org"), new EmailAddress("replyto2@example.org"), new EmailAddress("replyto3@example.org"));
    aData.to().addAll(new EmailAddress("to1@example.org"), new EmailAddress("to2@example.org"), new EmailAddress("to3@example.org"));
    aData.cc().addAll(new EmailAddress("cc1@example.org"), new EmailAddress("cc2@example.org"), new EmailAddress("cc3@example.org"));
    aData.bcc().addAll(new EmailAddress("bcc1@example.org"), new EmailAddress("bcc2@example.org"), new EmailAddress("bcc3@example.org"));
    // Ensure 3 fraction digits are present
    aData.setSentDateTime(PDTFactory.getCurrentLocalDateTimeMillisOnly().withNano(100 * (int) CGlobal.NANOSECONDS_PER_MILLISECOND));
    aData.setSubject("This is a test");
    aData.setBody("This is my mail that failed\nIt contains a lot of information.\nBla bla bla\nAll the best to you.");
    final EmailAttachmentList aAttachments = new EmailAttachmentList();
    aAttachments.addAttachment(new EmailAttachment("file1.txt", "Bla foo fasel".getBytes(StandardCharsets.UTF_8)));
    aAttachments.addAttachment(new EmailAttachment("file2.txt", "Bla foo fasel. Bla foo fasel.".getBytes(StandardCharsets.UTF_8)));
    aData.setAttachments(aAttachments);
    // Some custom attributes for fun
    aData.attrs().putIn("Attr1", "3.14");
    aData.attrs().putIn("Attr2", "Test attribute\nWe are multiline!");
    return aData;
}
Also used : EmailAttachment(com.helger.smtp.data.EmailAttachment) EmailData(com.helger.smtp.data.EmailData) EmailAttachmentList(com.helger.smtp.data.EmailAttachmentList) EmailAddress(com.helger.commons.email.EmailAddress) Nonnull(javax.annotation.Nonnull)

Aggregations

EmailAddress (com.helger.commons.email.EmailAddress)1 EmailAttachment (com.helger.smtp.data.EmailAttachment)1 EmailAttachmentList (com.helger.smtp.data.EmailAttachmentList)1 EmailData (com.helger.smtp.data.EmailData)1 Nonnull (javax.annotation.Nonnull)1