Skip to content

Latest commit

 

History

History
95 lines (74 loc) · 2.18 KB

newsletter.md

File metadata and controls

95 lines (74 loc) · 2.18 KB

Newsletter resources

Get newsletters

for (NewsletterEntity newsletter: mailQ.getNewsletters()) {
    System.out.println(newsletter.getName());
}

Create newsletter

Sender e-mail has to be created. See resource Sender email.

List<AttachmentEntity> attachments = new ArrayList<>();
AttachmentEntity attachmentEntity = new AttachmentEntity();
attachmentEntity.setDisplayName("attachment.jpg")
        .setLink("http://example.org/1.jpg")
        .setMimeType("image/jpeg")
        .setSource("LzlqLzRBQ==");
attachments.add(attachmentEntity);
NewsletterEntity newsletter = new NewsletterEntity();
newsletter.setCampaign("Winter sales")
        .setName("Example newsletter")
        .setSubject("20% sale")
        .setCode("XY-123")
        .setRecipientsListId(1L)
        .setSendAs("Company inc.")
        .setSenderEmail("newsletter@example.org")
        .setTemplateUrl("http://example.org/newsletter.html")
        .setAmpTemplateUrl("http://example.org/ampnewsletter.html")
        .setUnsubscribeTemplateUrl("http://example.org/unsubscribe.html")
        .setAutomaticTime(false)
        .setFrom(LocalDateTime.now().plusHours(5))
        .setTo(LocalDateTime.now().plusYears(1))
        .setTags("winter","sale")
        .setAttachments(attachments);
newsletter = mailQ.createNewsletter(newsletter);
System.out.println(newsletter.getId());

Get newsletters tag

for (TagEntity tag : mailQ.getNewslettersTags()) {
    System.out.println(tag.getName());
}

Get newsletter

NewsletterEntity newsletter = mailQ.getNewsletter(1L);
System.out.println(newsletter.getName());

Get newsletter by code

NewsletterEntity newsletter = mailQ.getNewsletterByCode("test");
System.out.println(newsletter.getName());

Update newsletter

NewsletterEntity newsletter = mailQ.getNewsletter(1L);
newsletter.setName("Summer sale");
mailQ.updateNewsletter(newsletter);

Delete newsletter

mailQ.deleteNewsletter(1L);

Start newsletter

mailQ.startNewsletter(1L);

Stop newsletter

mailQ.stopNewsletter(1L);

Send test e-mail

mailQ.sendTestEmail(1L,"john.doe@example.org")