Skip to content

Instantly share code, notes, and snippets.

@sendpulse
Last active August 29, 2015 14:23
Show Gist options
  • Save sendpulse/fdec460112abfc15ecd2 to your computer and use it in GitHub Desktop.
Save sendpulse/fdec460112abfc15ecd2 to your computer and use it in GitHub Desktop.
SendPulse REST API Usage Example for Java
// SendPulse's Java Library https://github.com/sendpulse/sendpulse-rest-api-java
import com.sendpulse.restapi.Sendpulse;
public class Example {
public static void main(String[] args) {
Sendpulse sendpulse = new Sendpulse(API_CLIENT_ID, API_CLIENT_SECRET);
Map<String, Object> from = new HashMap<String, Object>();
from.put("name", "Your Sender Name");
from.put("email", "[email protected]");
ArrayList<Map> to = new ArrayList<Map>();
Map<String, Object> elementto = new HashMap<String, Object>();
elementto.put("name", "Subscriber's name");
elementto.put("email", "[email protected]");
to.add(elementto);
Map<String, Object> emaildata = new HashMap<String, Object>();
emaildata.put("html","Your email content goes here");
emaildata.put("text","Your email text version goes here");
emaildata.put("subject","Testing SendPulse API");
emaildata.put("from",from);
emaildata.put("to",to);
Map<String, Object> result = (Map<String, Object>) sendpulse.smtpSendMail(emaildata);
System.out.println("Result: " + result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment