static void AsynchronousAPICalls()
        {
            string key = ConfigurationManager.AppSettings["MandrillKey"];
            string url = ConfigurationManager.AppSettings["MandrillUrl"];
            string fromEmail = ConfigurationManager.AppSettings["MandrillFromEmail"];
            string fromDisplayName = ConfigurationManager.AppSettings["MandrillFromEmailDisplay"];
            string toEmail = ConfigurationManager.AppSettings["MandrillToEmail"];
            string toDisplayName = ConfigurationManager.AppSettings["MandrillToEmailDisplay"];

            var madrilTest = new Mandrill(key, url);

            Console.WriteLine("1 sending ping request");
            madrilTest.PingAsync(new PingRequest(), PingHandler);

            Console.WriteLine("2 sending get info request");
            madrilTest.GetInfoAsync(new GetInfoRequest(), InfoHandler);

            Console.WriteLine("3 sending get sender data request");
            madrilTest.GetSenderDataAsync(new GetSenderDataRequest(), SenderDataHandler);

            Console.WriteLine("4 sending get templates request");
            madrilTest.GetTemplatesAsync(new GetTemplatesRequest(), TemaplateListHandler);

            Console.WriteLine("5 sending a create email request");
            var message = new EmailMessage
            {
                To = new List<EmailAddress> { new EmailAddress { Email = toEmail, Name = toDisplayName } },
                FromEmail = fromEmail,
                FromName = fromDisplayName,
                Subject = "Mandril Test Email",
                Html = "<strong>Html email in the house!</strong>",
                Text = "plain text email on the job"
            };

            madrilTest.SendEmailAsync(new SendEmailRequest { Message = message }, SendEmailHandler);
        }
        static void SynchronousAPICalls()
        {
            string key = ConfigurationManager.AppSettings["MandrillKey"];
            string url = ConfigurationManager.AppSettings["MandrillUrl"];
            string fromEmail = ConfigurationManager.AppSettings["MandrillFromEmail"];
            string fromDisplayName = ConfigurationManager.AppSettings["MandrillFromEmailDisplay"];
            string toEmail = ConfigurationManager.AppSettings["MandrillToEmail"];
            string toDisplayName = ConfigurationManager.AppSettings["MandrillToEmailDisplay"];
            string sampleTemplateHtml = ConfigurationManager.AppSettings["MandrillSampleTemplateHtml"];
            string sampleTemplateText = ConfigurationManager.AppSettings["MandrillSampleTemplateText"];

            var madrilTest = new Mandrill(key, url);

            // 1 Ping Mandrill
            var ping = madrilTest.Ping(new PingRequest());
            Console.WriteLine("Ping returns: " + ping);

            // 2 Get Info about the user associated with the current Mandril key
            var getInfo = madrilTest.GetInfo(new GetInfoRequest());
            Console.WriteLine(getInfo.Username);

            // 3 Get Some statistics about recently sent emails
            var senderDataResponses = madrilTest.GetSenderData(new GetSenderDataRequest());
            foreach (var sender in senderDataResponses)
            {
                Console.WriteLine("Sender:{0} Create Date:{1} Opens:{2}", sender.Address, sender.CreatedAt, sender.Opens);
            }

            // 4 Send a simple email message

            var message1 = new EmailMessage
            {
                To = new List<EmailAddress> { new EmailAddress { Email = toEmail, Name = toDisplayName } },
                FromEmail = fromEmail,
                Subject = "Mandril Test Email",
                Html = "<strong>Html email in the house!</strong>",
                Text = "plain text email on the job"
            };

            var sendResponses1 = madrilTest.SendEmail(new SendEmailRequest { Message = message1 });
            foreach (var sendEmailResponse in sendResponses1)
            {
                Console.WriteLine("Email send results: " + sendEmailResponse.Status);
            }

            // 5 Create a new template
            var newTemplate = new PostTemplateRequest
            {
                TemplateName = "Dummy Template",
                FromEmail = fromEmail,
                FromName = fromDisplayName,
                Subject = "My fancy template",
                Code = GetTextFromFile(sampleTemplateHtml),
                Text = GetTextFromFile(sampleTemplateText),
                Publish = true
            };

            var response = madrilTest.PostTemplate(newTemplate);
            Console.WriteLine(response.Slug);

            // 5 get a list of all templates
            var templates = madrilTest.GetTemplates(new GetTemplatesRequest());
            foreach (var templateInfo in templates)
            {
                Console.WriteLine("Template Name: {0} Slug: {1}", templateInfo.TemplateName, templateInfo.Slug);
            }

            // 6 Send a templated email with merge variables and and mc:edit region for the footer

            var message2 = new EmailMessage
            {
                To =
                    new List<EmailAddress>
                                {
                                    new EmailAddress {Email = toEmail, Name = toDisplayName}
                                },
                FromEmail = fromEmail,
                FromName = fromDisplayName,
                Html = null,
                Text = null
            };

            //string to = "*****@*****.**";
            message2.AddGlobalVariable("customername", toDisplayName);
            message2.AddGlobalVariable("orderdate", DateTime.Now.Date.ToShortDateString());
            message2.AddGlobalVariable("invoicedetails", "SMS Data fee $19.99");
            message2.Merge = true;

            var templateContents = new List<TemplateContent>
                    {
                        new TemplateContent {Name = "footer", Content = "Contact us at [email protected]"}

                    };

            var request = new SendEmailWithTemplateRequest
            {
                Message = message2,
                TemplateContent = templateContents,
                TemplateName = "Dummy Template"
            };

            var sendResponses = madrilTest.SendEmailWithTemplate(request);

            foreach (var sendEmailResponse in sendResponses)
            {
                Console.WriteLine("Templated email send results: " + sendEmailResponse.Status);
            }

            // 8 Update a template
            response = madrilTest.PutTemplate(new PutTemplateRequest { TemplateName = "Dummy Template", Code = "<strong>Updated!</strong>" });
            Console.WriteLine(response.Code);

            // 9 Delete a template
            var results = madrilTest.DeleteTemplate(new DeleteTemplateRequest { TemplateName = "Dummy Template" });
            Console.WriteLine(results.TemplateName + " was deleted");
        }