Skip to content

Instantly share code, notes, and snippets.

@demoore
Created November 14, 2014 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demoore/6ac9f5a8afa32bc7a1ad to your computer and use it in GitHub Desktop.
Save demoore/6ac9f5a8afa32bc7a1ad to your computer and use it in GitHub Desktop.
import java.util.HashMap;
import java.util.Map;
import com.sendwithus.SendWithUs;
import com.sendwithus.SendWithUsSendRequest;
import com.sendwithus.exception.SendWithUsException;
import com.sendwithus.model.DeactivatedDrips;
import com.sendwithus.model.Email;
import com.sendwithus.model.SendReceipt;
public class SendWithUsExample {
public static final String SENDWITHUS_API_KEY = "live_0c2b5084dc62c8ca7534b1315";
public static final String EMAIL_ID_WELCOME_EMAIL = "tem_zq8QcRFjAasd4f";
public static void main(String[] args) {
SendWithUs sendwithusAPI = new SendWithUs(SENDWITHUS_API_KEY);
// Send Welcome Email
Map<String, Object> recipientMap = new HashMap<String, Object>();
recipientMap.put("name", "Dylan"); // optional
recipientMap.put("address", "dylan@sendwithus.com");
// sender is optional
Map<String, Object> senderMap = new HashMap<String, Object>();
senderMap.put("name", "Company"); // optional
senderMap.put("address", "java@sendwithus.com");
senderMap.put("reply_to", "java@sendwithus.com"); // optional
// email data in to inject in the email template
Map<String, Object> emailDataMap = new HashMap<String, Object>();
Map<String, Object> subMap = new HashMap<String, Object>();
subMap.put("test", "hello");
subMap.put("test2", "hello2");
subMap.put("test3", "hello3");
emailDataMap.put("first_name", "Brad");
emailDataMap.put("link", "http://sendwithus.com/some_link");
emailDataMap.put("items", subMap);
// Example sending a simple email
try {
SendReceipt sendReceipt = sendwithusAPI.send(
EMAIL_ID_WELCOME_EMAIL,
recipientMap,
senderMap,
emailDataMap
);
System.out.println(sendReceipt);
} catch (SendWithUsException e) {
System.out.println(e.toString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment