Skip to content

Instantly share code, notes, and snippets.

@cdeutsch
Created November 8, 2013 21:53
Show Gist options
  • Select an option

  • Save cdeutsch/7378297 to your computer and use it in GitHub Desktop.

Select an option

Save cdeutsch/7378297 to your computer and use it in GitHub Desktop.
Mandrill example
var emailMessage = new EmailMessage
{
to = new List<EmailAddress>() { new EmailAddress() { email = model.Email, name = model.ShippingName } },
track_clicks = true,
track_opens = true
};
emailMessage.AddGlobalVariable("shipping_name", model.ShippingName.EmptyIfNull());
emailMessage.AddGlobalVariable("base_url", GetBaseUrl());
emailMessage.AddGlobalVariable("address1", model.Address1.EmptyIfNull());
emailMessage.AddGlobalVariable("address2", model.Address2.EmptyIfNull());
emailMessage.AddGlobalVariable("city", model.City.EmptyIfNull());
emailMessage.AddGlobalVariable("state", model.State.EmptyIfNull());
emailMessage.AddGlobalVariable("zipcode", model.ZipCode.EmptyIfNull());
var mandrillApi = new MandrillApi(ConfigurationManager.AppSettings["MandrillApiKey"]);
mandrillApi.SendMessage(emailMessage, templateName, templateContents);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment