Exemplo n.º 1
0
        public void NotifyUser(string email,string name,string subject,string body,string templateName)
        {
            var m = new MandrillApi(key);
            //Mail settings for mandrill
            var message = new MN.Messages.Message();
            message.Subject = subject;
            message.FromEmail = ConfigurationManager.AppSettings["SupportEmailID"];
            message.FromName = "LockYourStay";
            message.To = new[] { new MN.Messages.Recipient(email, email) };

            //mergevars for dynamic content in mandrill template
            var globalMergeVars = new Mandrill.Merges();
            globalMergeVars.Add("SUBJECT", message.Subject);
            globalMergeVars.Add("NAME", name);
            globalMergeVars.Add("BODY", body);

            message.GlobalMergeVars = globalMergeVars; // common information for all receipient

            //dynamic template content
            var templateContent = new List<Mandrill.NameContentPair<string>>();
            templateContent.Add(new Mandrill.NameContentPair<string>("SUBJECT", message.Subject));
            templateContent.Add(new Mandrill.NameContentPair<string>("NAME", name));
            templateContent.Add(new Mandrill.NameContentPair<string>("BODY", body));

            //Send mail
            m.SendTemplate(templateName, templateContent, message);
        }
Exemplo n.º 2
0
        public void NotifySuperAdmin(string email,string subject, string body, string templateName)
        {
            var toList = ConfigurationManager.AppSettings["SuperAdminToEmails"].Split(';');
            var recipientCount = toList.Count();
            var count = 0;

            MN.Messages.Recipient[] recipients = new MN.Messages.Recipient[recipientCount];
            foreach (var to in toList)
            {
                recipients[count] = new MN.Messages.Recipient(to, to);
                count++;
            }
            var m = new MandrillApi(key);
            //Mail settings for mandrill
            var message = new MN.Messages.Message();
            message.Subject = subject;
            message.FromEmail = ConfigurationManager.AppSettings["SupportEmailID"];
            message.FromName = "LockYourStay";
            message.To = recipients;

            //mergevars for dynamic content in mandrill template
            var globalMergeVars = new Mandrill.Merges();
            globalMergeVars.Add("SUBJECT", message.Subject);
            globalMergeVars.Add("BODY", body);

            message.GlobalMergeVars = globalMergeVars; // common information for all receipient

            //dynamic template content
            var templateContent = new List<Mandrill.NameContentPair<string>>();
            templateContent.Add(new Mandrill.NameContentPair<string>("SUBJECT", message.Subject));
            templateContent.Add(new Mandrill.NameContentPair<string>("BODY", body));

            //Send mail
            m.SendTemplate(templateName, templateContent, message);
        }