use of com.cribbstechnologies.clients.mandrill.model.TemplateContent in project Java-Mandrill-Wrapper by cribbstechnologies.
the class MessagesTest method testSendTemplatedMessage.
@Test
public void testSendTemplatedMessage() {
MandrillTemplatedMessageRequest request = new MandrillTemplatedMessageRequest();
MandrillMessage message = new MandrillMessage();
Map<String, String> headers = new HashMap<String, String>();
message.setFrom_email(props.getProperty("email.from"));
message.setFrom_name("Big Jimmy");
message.setHeaders(headers);
message.setSubject("This is the subject");
MandrillRecipient[] recipients = new MandrillRecipient[] { new MandrillRecipient(props.getProperty("email.to.name1"), props.getProperty("email.to.address1")), new MandrillRecipient(props.getProperty("email.to.name2"), props.getProperty("email.to.address2")) };
message.setTo(recipients);
message.setTrack_clicks(true);
message.setTrack_opens(true);
String[] tags = new String[] { "tag1", "tag2", "tag3" };
message.setTags(tags);
request.setMessage(message);
List<TemplateContent> content = new ArrayList<TemplateContent>();
request.setTemplate_content(content);
request.setTemplate_name("template2");
List<MergeVar> globalMergeVars = new ArrayList<MergeVar>();
globalMergeVars.add(new MergeVar("username", "bcribs"));
globalMergeVars.add(new MergeVar("registration_url", "http://myserver.com/register?userid=bcribs"));
message.setGlobal_merge_vars(globalMergeVars);
try {
messagesRequest.sendTemplatedMessage(request);
} catch (RequestFailedException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations