Skip to content

Instantly share code, notes, and snippets.

@thinkingserious
Created February 1, 2014 02:08
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 thinkingserious/8746978 to your computer and use it in GitHub Desktop.
Save thinkingserious/8746978 to your computer and use it in GitHub Desktop.
SendEmailWithSendGrid.java for SendGrid Glass GDK Example
package com.thinkingserious.sendgrid.glass.gdk.example;
import java.util.Hashtable;
import android.os.AsyncTask;
import com.github.sendgrid.SendGrid;
// This is the magic that sends the email through SendGrid's web API.
public class SendEmailWithSendGrid extends AsyncTask<Hashtable<String,String>, Void, String> {
Utils creds = new Utils();
@Override
protected String doInBackground(Hashtable<String,String>... params) {
Hashtable<String,String> h = params[0];
SendGrid sendgrid = new SendGrid(creds.getUsername(),creds.getPassword());
sendgrid.setFrom(creds.getFromAddress());
sendgrid.addTo(h.get("to"));
sendgrid.setSubject(h.get("subject"));
sendgrid.setText(h.get("text") + "\n\n#throughglass");
String response = sendgrid.send();
return response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment