Skip to content

Instantly share code, notes, and snippets.

@AymericG
Created May 2, 2012 09:31
Show Gist options
  • Save AymericG/2575531 to your computer and use it in GitHub Desktop.
Save AymericG/2575531 to your computer and use it in GitHub Desktop.
Processing incoming emails from SendGrid.
[HttpPost]
[ValidateInput(false)]
public ActionResult ProcessIncomingEmail(IncomingEmail email)
{
var serializer = new JavaScriptSerializer();
serializer.RegisterConverters(new[] { new DynamicJsonConverter() });
email.envelope = serializer.Deserialize(HttpContext.Request.Form["envelope"], typeof(object));
// Parse incoming to: email address
// Do something
return new EmptyResult();
}
public class IncomingEmail
{
public string text { get; set; }
public string html { get; set; }
public string from { get; set; }
public string to { get; set; }
public dynamic envelope { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment