private static async Task <string> SendEmail(EmailMessage emailMessage, EmailAddress emailAddress = null, Dictionary <string, string> dictionary = null, string emailTemplate = "") { // Sensitive information, needs to be properly encoded before deployment. Mandrill.MandrillApi api = new Mandrill.MandrillApi("rtHftXQYhGroTsPBzWBnbQ"); List <EmailResult> results = new List <EmailResult>(); if (String.IsNullOrEmpty(emailTemplate)) { Mandrill.Requests.Messages.SendMessageRequest request = new Mandrill.Requests.Messages.SendMessageRequest(emailMessage); results = await api.SendMessage(request); } else { if (dictionary != null) { foreach (var item in dictionary) { if (emailAddress != null) { emailMessage.AddRecipientVariable(emailAddress.Email, item.Key, item.Value); } } } Mandrill.Requests.Messages.SendMessageTemplateRequest request = new Mandrill.Requests.Messages.SendMessageTemplateRequest(emailMessage, emailTemplate); results = await api.SendMessageTemplate(request); } return(results.FirstOrDefault().Status.ToString()); }