using System.Collections.Generic;
using System.Threading.Tasks;
public class MandrillClient
private readonly HttpClient httpClient;
private readonly string apiKey;
private readonly string templateName;
public MandrillClient(HttpClient httpClient)
this.httpClient = httpClient;
apiKey = Environment.GetEnvironmentVariable("MandrillApiKey");
templateName = Environment.GetEnvironmentVariable("MandrillTemplateName");
public async Task<string> CheckMailStatus(string mailId)
var data = new Dictionary<string, string> {
var json = JsonConvert.SerializeObject(data);
var stringContent = new StringContent(json);
HttpResponseMessage response = await httpClient.PostAsync("/api/1.0/messages/info", stringContent);
if (response.IsSuccessStatusCode)
var responseString = await response.Content.ReadAsStringAsync();
return responseString.Trim();
throw new Exception($"{response.ReasonPhrase},{response.StatusCode}");