Ejemplo n.º 1
0
        public override void Execute()
        {
            var apiKey = EnvironmentVariableHelper.GetEnvironmentVariable(mandrillAPIKey);
              var fromEmail = EnvironmentVariableHelper.GetEnvironmentVariable(fromEmailKey);

              var api = new MandrillApi (apiKey);

              Console.WriteLine("Sending {0} emails.", In.DueReminders.Length);
              foreach (var reminder in In.DueReminders) {
            var results = api.SendMessage(
              new EmailMessage {
            to = new List<EmailAddress> { new EmailAddress { email = reminder.Contact } },
            from_email = fromEmail,
            subject = "Reminder!",
            text = reminder.Message
            });

            // This assumes that emails are sent one at time to each address, therefore just look
            // at the first result.
            EmailResult result = results[0];
            if (result.Status == EmailResultStatus.Sent) {
              Out.Sent++;
            } else {
              Out.Errors++;
              Console.WriteLine(
            "Email {0} failed with a status of {1} and reason of {2}.",
            result.Email,
            result.Status,
            result.RejectReason
              );
            }
              }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// SendMailByMandrill
        /// this function is used for Get Rejected Mail of Mandrill</summary></summary>
        /// the main parameter is
        /// <add key="host" value="smtp.mandrillapp.com" />
        /// <param name="port"></param>
        /// <add key="port" value="25" />
        /// <param name="from"></param>
        /// <add key="username" value="socioboard"/>
        /// <param name="passsword"></param>
        /// <add key="fromemail" value="*****@*****.**"/>
        /// <param name="to"></param>
        /// <add key="password" value="xyz" />
        /// <param name="bcc"></param>
        /// add key="tomail" value="*****@*****.**" />
        /// its return : List<RejectInfo> ie hardbouce , softbounce, rejected etc.
        /// /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="sendgridUserName"></param>
        /// <param name="sendgridPassword"></param>
        /// <returns></returns>

        public List <RejectInfo> GetListRejectInfoByMandrill(string Host, int port, string from, string passsword, string to, string bcc, string cc, string subject, string body, string sendgridUserName, string sendgridPassword)
        {
            string            sendMailByMandrill = string.Empty;
            List <RejectInfo> ri = new List <RejectInfo>();

            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                //message.from_email = from;
                //message.from_name = from;//"AlexPieter";
                message.from_email = from;
                message.from_name  = "Socioboard Support";
                message.html       = body;
                message.subject    = subject;
                message.to         = new List <Mandrill.EmailAddress>()
                {
                    new Mandrill.EmailAddress(to)
                };

                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(sendgridPassword, false);


                ri = mandrillApi.ListRejects();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
                sendMailByMandrill = ex.Message;
            }

            return(ri);
        }
Ejemplo n.º 3
0
        protected async void Button1_Click(object sender, EventArgs e)
        {




                MandrillApi api = new MandrillApi("Mandrill Api Key", true);

                IEnumerable<EmailAddress> addresses = new[]
            {
                new EmailAddress("*****@*****.**", "Name Of the Contact"),
                
            };




                var message = new EmailMessage();

                message.FromEmail = "*****@*****.**";
                message.FromName = "Your name";
            message.Html = "emailbody";
                message.Text = "emailbodytext";
            message.Subject = "subject";
                message.To = addresses;
              

                SendMessageRequest req = new SendMessageRequest(message);

                var returnvalue = await api.SendMessage(req);
             
            }
Ejemplo n.º 4
0
        public static List<EmailResult> SendMailTemplate(List<string> toMails, string templateName, List<merge_var> mergeVars, string subject)
        {
            try
            {
                var api = new MandrillApi(_mandrillApiKey);

                var email = new EmailMessage
                                {
                                    from_email = _senderEmail,
                                    subject = subject
                                };

                var to = toMails.Select(mailTo => new EmailAddress(mailTo)).ToList();

                email.to = to;
                foreach (merge_var item in mergeVars)
                {
                    email.AddGlobalVariable(item.name, item.content);
                }

                var result = api.SendMessageAsync(email, templateName, null);
                return result.Result;
            }
            catch (Exception ex)
            {
                EventLogger.Log(ex);
                return null;
                //ManagementBLL.LogError("SendMailMandrill", ex.Message, "EmailHelper", string.Empty);
            }
        }
Ejemplo n.º 5
0
        public static async void EnviarMailRegistro(string nombreFranquicia, string from, string para, string nombrePara, string confirmKey,
            string nombre, string password)
        {
            MandrillApi api = new MandrillApi("aEBsx-ctFG9KeItcRm5aCQ");
            UserInfo info = await api.UserInfo();
            Console.WriteLine(info.Username);

            var email = new Mandrill.Models.EmailMessage();

            var correos = new List<EmailAddress>();
            correos.Add(new EmailAddress(para, nombrePara));

            email.To = correos;

            email.Subject = String.Format("Confirmación de registro a {0}", nombreFranquicia);

            email.FromEmail = from;
            email.FromName = nombreFranquicia;


            email.TrackOpens = true;
            email.Html =
                $"Hola {nombrePara}, url: {"http://localhost:49608/Usuario/ConfirmacionCorreo?confirmKey=" + confirmKey} Adicionalmente, esta es tu password para cambiar la contraseña: { password }";

            await api.SendMessage(new SendMessageRequest(email));
        }
Ejemplo n.º 6
0
        public static List<EmailResult> SendMail(List<string> toMails, string subject, string htmlBody, bool async = false)
        {
            try
            {
                var api = new MandrillApi(_mandrillApiKey);

                var email = new EmailMessage()
                {
                    from_email = _senderEmail,
                    subject = subject,
                    html = htmlBody
                };
                var to = toMails.Select(mailTo => new EmailAddress(mailTo)).ToList();

                email.to = to;
                if (async)
                {
                    var result = api.SendMessageAsync(email);
                    return result.Result;
                }
                return api.SendMessage(email);
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Ejemplo n.º 7
0
        public string SendMail(string from, string passsword, string to, string bcc, string cc, string subject, string body, string MandrillUserName = "", string MandrillPassword = "")
        {
            string sendMailByMandrill = string.Empty;
            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                message.from_email = from;
                message.from_name = from;
                message.html = body;
                message.subject = subject;
                message.to = new List<Mandrill.EmailAddress>()
                {
                  new Mandrill.EmailAddress(to)
                };
                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(MandrillPassword, false);
                var results = mandrillApi.SendMessage(message);

                foreach (var result in results)
                {
                    if (result.Status != Mandrill.EmailResultStatus.Sent || result.Status == Mandrill.EmailResultStatus.Queued)
                    {
                        sendMailByMandrill = "Success";
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return sendMailByMandrill;
        }
Ejemplo n.º 8
0
        public string SendInvitationMailByMandrill(string SenderEmail, string SenderName, string FriendsEmail, string password, string body)
        {
            string sendMailByMandrill = string.Empty;

            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                message.from_email = SenderEmail;
                message.from_name  = SenderName;
                message.html       = body;
                message.subject    = "Your friend " + SenderName + "has invited you to join socioboard";
                message.to         = new List <Mandrill.EmailAddress>()
                {
                    new Mandrill.EmailAddress(FriendsEmail)
                };
                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(password, false);
                var results = mandrillApi.SendMessage(message);
                foreach (var result in results)
                {
                    if (result.Status == Mandrill.EmailResultStatus.Sent || result.Status == Mandrill.EmailResultStatus.Queued)
                    {
                        sendMailByMandrill = "success";
                    }
                    else
                    {
                        sendMailByMandrill = "failed";
                    }
                }
            }
            catch (Exception ex)
            {
                sendMailByMandrill = "failed";
            }
            return(sendMailByMandrill);
        }
Ejemplo n.º 9
0
        public string ReplyForCareerMail(string from, string body, string subject, string to, string password)
        {
            string sendMailByMandrill = string.Empty;

            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                message.from_email = from;
                message.from_name  = "Socioboard Support";
                message.html       = body;
                message.subject    = subject;
                message.to         = new List <Mandrill.EmailAddress>()
                {
                    new Mandrill.EmailAddress(to)
                };
                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(password, false);
                var    results = mandrillApi.SendMessage(message);
                string status  = string.Empty;
                foreach (var result in results)
                {
                }
                sendMailByMandrill = "Success";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
                sendMailByMandrill = ex.Message;
            }
            return(sendMailByMandrill);
        }
        public static IList<MandrillSendMessageResponse> customSend(object model, MandrillTemplates template)
        {
            var api = new MandrillApi("IRWMe1g1dCTrG6uOZEy7gQ");
            var message = new MandrillMessage();
            message.FromEmail = "*****@*****.**";
            message.AddTo("*****@*****.**");
            message.ReplyTo = "*****@*****.**";
            foreach (var prop in model.GetType().GetProperties())
            {
                var value = prop.GetValue(model, null);
                if(value != null)
                    message.AddGlobalMergeVars(prop.Name, prop.GetValue(model, null).ToString());
            }
            string templateName = string.Empty;

            switch (template)
            {
                case MandrillTemplates.Lead: templateName = "customer-lead"; break;
                case MandrillTemplates.Invoice: templateName = "customer-invoice"; break;
                default: break;
            }

            if (!string.IsNullOrEmpty(templateName))
            {
                var result = api.Messages.SendTemplate(message, templateName);
                return result;
            }
            return null;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// SendMailByMandrill
        /// this function is used for Get Rejected Mail of Mandrill</summary></summary>
        /// the main parameter is
        /// <add key="host" value="smtp.mandrillapp.com" />
        /// <param name="port"></param>
        /// <add key="port" value="25" />
        /// <param name="from"></param>
        /// <add key="username" value="socioboard"/>
        /// <param name="passsword"></param>
        /// <add key="fromemail" value="*****@*****.**"/>
        /// <param name="to"></param>
        /// <add key="password" value="xyz" />
        /// <param name="bcc"></param>
        /// add key="tomail" value="*****@*****.**" />
        /// its return : List<RejectInfo> ie hardbouce , softbounce, rejected etc.
        /// /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="sendgridUserName"></param>
        /// <param name="sendgridPassword"></param>
        /// <returns></returns>
        public List<RejectInfo> GetListRejectInfoByMandrill(string Host, int port, string from, string passsword, string to, string bcc, string cc, string subject, string body, string sendgridUserName, string sendgridPassword)
        {
            string sendMailByMandrill = string.Empty;
            List<RejectInfo> ri = new List<RejectInfo>();
            try
            {

                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                //message.from_email = from;
                //message.from_name = from;//"AlexPieter";
                message.from_email = from;
                message.from_name = "Socioboard Support";
                message.html = body;
                message.subject = subject;
                message.to = new List<Mandrill.EmailAddress>()
                {
                  new Mandrill.EmailAddress(to)
                };

                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(sendgridPassword, false);

                ri = mandrillApi.ListRejects();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
                sendMailByMandrill = ex.Message;
            }

            return ri;
        }
Ejemplo n.º 12
0
        public void SendEmail()
        {
            //create a new message object
            var message = new MandrillApi(Apikey, true);

            //send the mail
            try
            {
                var emailMessage = new EmailMessage()
                {
                    to = To,
                    subject = Subject,
                    raw_message = Message,
                    from_email = From.email,
                    from_name = From.name
                };

                //message.SendRawMessage(emailMessage);

                message.SendMessage(To, Subject, Message, From, new DateTime());
            }
            catch (System.Exception ex)
            {
                throw;
                // log the error
            }
        }
Ejemplo n.º 13
0
        public string SendMail(string from, string passsword, string to, string bcc, string cc, string subject, string body, string MandrillUserName = "", string MandrillPassword = "")
        {
            string sendMailByMandrill = string.Empty;

            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                message.from_email = from;
                message.from_name  = from;
                message.html       = body;
                message.subject    = subject;
                message.to         = new List <Mandrill.EmailAddress>()
                {
                    new Mandrill.EmailAddress(to)
                };
                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(MandrillPassword, false);
                var results = mandrillApi.SendMessage(message);

                foreach (var result in results)
                {
                    if (result.Status != Mandrill.EmailResultStatus.Sent || result.Status == Mandrill.EmailResultStatus.Queued)
                    {
                        sendMailByMandrill = "Success";
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(sendMailByMandrill);
        }
Ejemplo n.º 14
0
 public void SendSellerMessage(int messageId, string pathToTemplates, string pathToMedia)
 {
     var record = _settingsService.GetAllSettings().List().FirstOrDefault();
     var api = new MandrillApi(record.ApiKey);
     var mandrillMessage = new MandrillMessage() { };
     var message = _messageService.GetMessage(messageId);
     mandrillMessage.MergeLanguage = MandrillMessageMergeLanguage.Handlebars;
     mandrillMessage.FromEmail = message.Sender;
     mandrillMessage.Subject = message.Subject;
     List<LinkOrderCampaignProductRecord> ordersList = _orderService.GetProductsOrderedOfCampaign(message.CampaignId).ToList();
     var campaign = _campaignService.GetCampaignById(message.CampaignId);
     List<MandrillMailAddress> emails = new List<MandrillMailAddress>();
     foreach (var item in ordersList)
     {
         emails.Add(new MandrillMailAddress(item.OrderRecord.Email, "user"));
         FillMessageMergeVars(mandrillMessage, item);
     }
     mandrillMessage.To = emails;
     string text = System.IO.File.ReadAllText(pathToTemplates+"seller-template.html");
     string messageText = text.Replace("---MessageContent---", message.Text);
     messageText = messageText.Replace("---SellerEmail---", message.Sender);
     messageText = messageText.Replace("---CampaignTitle---", campaign.Title);
     string previewUrl = pathToMedia + "/Media/campaigns/" + message.CampaignId + "/" + campaign.Products[0].Id + "/normal/front.png";
     messageText = messageText.Replace("---CampaignPreviewUrl---", previewUrl);
     mandrillMessage.Html = messageText;
     var res = SendTmplMessage(api, mandrillMessage);
     _notifier.Information(T("Message has been sent!"));
     message.IsApprowed = true;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Create a new instance of the MandrillMailSender using an API key provided in AppSettings as key MandrillApiKey.
        /// </summary>
        public MandrillMailSender()
        {
            var apiKey = ConfigurationManager.AppSettings["MandrillApiKey"];
            if(string.IsNullOrWhiteSpace(apiKey))
                throw new InvalidOperationException("The AppSetting 'MandrillApiKey' is not defined. Either define this configuration section or use the constructor with apiKey parameter.");

            _mandrillClient = new MandrillApi(apiKey);
        }
Ejemplo n.º 16
0
        public MandrillMailSender(string apiKey, IMailInterceptor interceptor)
        {
            if (string.IsNullOrWhiteSpace(apiKey))
                throw new ArgumentNullException("apiKey",
                    "The AppSetting 'MandrillApiKey' is not defined. Either define this configuration section or use the constructor with apiKey parameter.");

            _interceptor = interceptor;
            _client = new MandrillApi(apiKey);
        }
Ejemplo n.º 17
0
        //static string MandrillBaseUrl = ConfigurationManager.AppSettings["smtp.mandrillapp.com"];
        //static Guid MandrillKey = new Guid(ConfigurationManager.AppSettings["xBhdpEwsVOC689CTDqzlkw"]);

        public static void SendSingleMail(List <M.EmailAddress> argToAddress, string argSubject, string argContent, List <M.attachment> argAttachment)
        {
            try
            {
                //string activationLink = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Register/Activation.aspx?id=" + "";

                Cursor.Current = Cursors.WaitCursor;

                DataTable dt = new DataTable();
                dt = CommFun.GetMandrillSetting(2);
                if (dt == null)
                {
                    return;
                }
                if (dt.Rows.Count == 0)
                {
                    return;
                }

                string sFromName     = CommFun.IsNullCheck(dt.Rows[0]["FromName"], CommFun.datatypes.vartypestring).ToString();
                string sUserId       = CommFun.IsNullCheck(dt.Rows[0]["UserId"], CommFun.datatypes.vartypestring).ToString();
                string sKeyId        = CommFun.IsNullCheck(dt.Rows[0]["KeyId"], CommFun.datatypes.vartypestring).ToString();
                string sTemplateName = CommFun.IsNullCheck(dt.Rows[0]["TemplateId"], CommFun.datatypes.vartypestring).ToString();

                M.MandrillApi api = new M.MandrillApi(sKeyId, true);

                M.EmailMessage emailmsg = new M.EmailMessage();
                emailmsg.from_name   = sFromName;
                emailmsg.from_email  = sUserId;
                emailmsg.to          = argToAddress;
                emailmsg.attachments = argAttachment;
                emailmsg.merge       = true;
                emailmsg.AddGlobalVariable("SUBJECT", argSubject);
                emailmsg.AddGlobalVariable("BODY", argContent);

                emailmsg.AddGlobalVariable("FlatNo", "5-102");
                emailmsg.AddGlobalVariable("PaidAmount", "0");
                emailmsg.AddGlobalVariable("Balance", "6,70,070.00");
                emailmsg.AddGlobalVariable("Project", "Sky Dugar");
                emailmsg.AddGlobalVariable("Company", "Dugar");

                List <M.TemplateContent> tempContent = new List <M.TemplateContent>();
                tempContent.Add(new M.TemplateContent()
                {
                    name = sTemplateName
                });

                List <M.EmailResult> errorMsg = api.SendMessage(emailmsg, sTemplateName, tempContent);

                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 18
0
        // TODO: Probably should set this up for multiple email methods - SMTP through Gmail as one option
        /// <summary>
        /// Creates a service to send SMS messages.
        /// </summary>
        /// <param name="mandrillApiKey">API key for the Mandrill emailing service.</param>
        /// <param name="fromAddress">The from address to show in your message.</param>
        public SmsService(string mandrillApiKey, string fromAddress)
        {
            _fromAddress = fromAddress;
            _api = new MandrillApi(mandrillApiKey);

            // Get carriers
            var carrierCsv = new MemoryStream(Encoding.UTF8.GetBytes(Resources.Carriers));
            var carriers = CsvDynamic.CsvDynamic.Convert(carrierCsv);
            _templates = carriers.ToDictionary(c => ((string) c.Carrier).ToUpperInvariant(), c => (string) c.Format);
        }
        public MandrillNotifierEmailer(IUrlConstructor urlConstructor, ISettingService settingService)
        {
            _setting= settingService.GetCurrentSetting();
            _urlConstructor = urlConstructor;

            if (_setting.UseMandrill)
            {
                _api = new MandrillApi(_setting.MandrillApiKey);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Send an email
        /// </summary>
        /// <param name="request">Contains detailed email info and optionally provider info (such as ApiKeys)</param>
        /// <param name="messageId">The message id returned by the service provider</param>
        /// <param name="detailMessage">The message returned by the service provider, e.g. "failed to send message", "Sent", "Message Queued for delivery"</param>
        /// <returns>True if email was sent successfully</returns>
        public override bool SendMail(SendMailRequest request, out string messageId, out string detailMessage)
        {
            // Create request
            string apiKey = GetApiKey(request);
            MandrillApi api = new MandrillApi(apiKey);

            // Email details
            EmailMessage msg = new EmailMessage();
            msg.FromEmail = request.From;
            msg.To = request.To.Select(e=>new EmailAddress(e));
            msg.Text = request.Text;

            // Send email
            SendMessageRequest smReq = new SendMessageRequest(msg);
            Task<List<EmailResult>> task = api.SendMessage(smReq);
            task.Wait();

            // process response
            messageId = "";
            detailMessage = "";

            EmailResult er = null;
            if (task.Result != null && task.Result.Count >0)
            {
                er = task.Result[0];
            }

            if (er == null)
            {
                detailMessage = "Invalid return result from provider.";
                return false;
            }

            messageId = er.Id;
            detailMessage = er.Status.ToString();

            if (er.Status == EmailResultStatus.Queued
                || er.Status == EmailResultStatus.Scheduled
                || er.Status == EmailResultStatus.Sent)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 21
0
        //vikash
        public string SendCareerMailByMandrill(string Host, int port, string from, string passsword, string to, string bcc, string cc, string subject, string body, string sendgridUserName, string sendgridPassword, string file, string filename, string filetype)
        {
            string sendMailByMandrill = string.Empty;

            try
            {
                var fileBytes = File.ReadAllBytes(file);
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                message.from_email  = from;
                message.from_name   = "Socioboard Support";
                message.html        = body;
                message.subject     = subject;
                message.attachments = new[]
                {
                    new attachment
                    {
                        content = Convert.ToBase64String(fileBytes),
                        name    = filename,
                        type    = filetype
                    }
                };
                message.to = new List <Mandrill.EmailAddress>()
                {
                    new Mandrill.EmailAddress(to)
                };
                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(sendgridPassword, false);
                var    results = mandrillApi.SendMessage(message);
                string status  = string.Empty;
                foreach (var result in results)
                {
                    if (result.Status != Mandrill.EmailResultStatus.Sent)
                    {
                        logger.Error(result.Email + " " + result.RejectReason);
                    }
                }

                sendMailByMandrill = "Success";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
                sendMailByMandrill = ex.Message;
            }

            return(sendMailByMandrill);
        }
Ejemplo n.º 22
0
        public string SendMailByMandrill(string Host, int port, string from, string name, string passsword, string to, string bcc, string cc, string subject, string body, string sendgridUserName, string sendgridPassword)
        {
            string sendMailByMandrill = string.Empty;

            //GetStatusFromSendMailByMandrill(Host, port, from, passsword, to, bcc, cc, subject, body, sendgridUserName, sendgridPassword);

            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                //message.from_email = from;
                //message.from_name = from;//"AlexPieter";
                message.from_email = from;
                message.from_name  = name;
                message.html       = body;
                message.subject    = subject;
                message.to         = new List <Mandrill.EmailAddress>()
                {
                    new Mandrill.EmailAddress(to)
                };

                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(sendgridPassword, false);
                var    results = mandrillApi.SendMessage(message);
                string status  = string.Empty;
                foreach (var result in results)
                {
                    if (result.Status != Mandrill.EmailResultStatus.Sent)
                    {
                        logger.Error(result.Email + " " + result.RejectReason);
                    }
                    //status = Mandrill.EmailResultStatus.Sent.ToString();
                    //  LogManager.Current.LogError(result.Email, "", "", "", null, string.Format("Email failed to send: {0}", result.RejectReason));
                }

                sendMailByMandrill = "Success";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
                sendMailByMandrill = ex.Message;
            }

            return(sendMailByMandrill);
        }
Ejemplo n.º 23
0
 public void SendAcceptanceNotificationToGroup(Member member)
 {
     var api = new MandrillApi(_configuration.MadrillApiKey);
     var result = api.SendMessage(
         new EmailMessage()
         {
             to =
                 new List<EmailAddress>()
                 {
                     new EmailAddress {email = _configuration.MadrillOriginTarget}
                 },
             subject = member.FullName
         },
         "devlink-accept-invitation",
         new List<TemplateContent>()
         {
             new TemplateContent() {name = "candidate", content = member.FullName},
         });
 }
Ejemplo n.º 24
0
        public string SendMailWithAttachment(string from, string passsword, string to, string bcc, string cc, string subject, string body, string file, string filename, string filetype, string MandrillUserName = "", string MandrillPassword = "")
        {
            string sendMailByMandrill = string.Empty;

            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                message.from_email = from;
                message.from_name  = from;
                message.html       = body;
                message.subject    = subject;
                var fileBytes = File.ReadAllBytes(file);
                message.attachments = new[]
                {
                    new attachment
                    {
                        content = Convert.ToBase64String(fileBytes),
                        name    = filename,
                        type    = filetype
                    }
                };
                message.to = new List <Mandrill.EmailAddress>()
                {
                    new Mandrill.EmailAddress(to)
                };
                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(MandrillPassword, false);
                var results = mandrillApi.SendMessage(message);

                foreach (var result in results)
                {
                    if (result.Status != Mandrill.EmailResultStatus.Sent || result.Status == Mandrill.EmailResultStatus.Queued)
                    {
                        sendMailByMandrill = "Success";
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(sendMailByMandrill);
        }
        // POST api/event
        public HttpResponseMessage PostEvent(FormDataCollection value)
        {
            var events = Mandrill.JSON.Parse<List<Mandrill.WebHookEvent>>(value.Get("mandrill_events"));

            MandrillApi api = new MandrillApi(Settings.Default.MandrillApiKey);

            foreach (var evt in events)
            {
                if (HardBounceOrUnsubscribeFromMailChimpList(evt))
                {
                    UnsubscribeEmailfromMailChimpList(evt);
                }
                else if (HardBounceSentFromPeachtreeDataDomain(evt))
                {
                    CreateAndSendEmailMessageFromTemplate(evt);
                }
            }

            return Request.CreateErrorResponse(HttpStatusCode.OK, "Received");
        }
Ejemplo n.º 26
0
        public string SendMailWithAttachment(string from, string passsword, string to, string bcc, string cc, string subject, string body, string file, string filename, string filetype, string MandrillUserName = "", string MandrillPassword = "")
        {
            string sendMailByMandrill = string.Empty;
            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                message.from_email = from;
                message.from_name = from;
                message.html = body;
                message.subject = subject;
                var fileBytes = File.ReadAllBytes(file);
                message.attachments = new[]
                              {
                                  new attachment
                                  {
                                      content = Convert.ToBase64String(fileBytes),
                                      name = filename,
                                      type = filetype
                                  }
                              };
                message.to = new List<Mandrill.EmailAddress>()
                {
                  new Mandrill.EmailAddress(to)
                };
                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(MandrillPassword, false);
                var results = mandrillApi.SendMessage(message);

                foreach (var result in results)
                {
                    if (result.Status != Mandrill.EmailResultStatus.Sent || result.Status == Mandrill.EmailResultStatus.Queued)
                    {
                        sendMailByMandrill = "Success";
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return sendMailByMandrill;
        }
Ejemplo n.º 27
0
        public string SendAddNewsLatterMail(string Host, int port, string from, string passsword, string to, string subject, string body)
        {
            string sendMailByMandrill = string.Empty;

            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                message.from_email = from;
                message.from_name  = from;
                message.html       = body;
                message.subject    = subject;
                message.to         = new List <Mandrill.EmailAddress>()
                {
                    new Mandrill.EmailAddress(to)
                };

                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(passsword, false);
                var results = mandrillApi.SendMessage(message);

                foreach (var result in results)
                {
                    if (result.Status != Mandrill.EmailResultStatus.Sent)
                    {
                        // logger.Error(result.Email + " " + result.RejectReason);
                    }
                    //  LogManager.Current.LogError(result.Email, "", "", "", null, string.Format("Email failed to send: {0}", result.RejectReason));
                }

                sendMailByMandrill = "Success";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //logger.Error(ex.Message);
            }

            return(sendMailByMandrill);
        }
Ejemplo n.º 28
0
 public void SendInvitationToGroup(Invitation invitation, string vouched)
 {
     var api = new MandrillApi(_configuration.MadrillApiKey);
     var result = api.SendMessage(
         new EmailMessage()
         {
             to =
                 new List<EmailAddress>()
                 {
                     new EmailAddress {email = _configuration.MadrillOriginTarget}
                 },
             subject = invitation.FullName
         },
         "devlink-submit-invitation",
         new List<TemplateContent>()
         {
             new TemplateContent() {name = "candidate", content = invitation.FullName},
             new TemplateContent() {name = "linkedin", content = invitation.LinkedIn},
             new TemplateContent() {name = "github", content = invitation.GitHub},
             new TemplateContent() {name = "vouchedby", content = vouched},
             new TemplateContent() {name = "testimonal", content = invitation.Testimonial}
         });
 }
 private void Send(Lead model)
 {
     var api = new MandrillApi("IRWMe1g1dCTrG6uOZEy7gQ");
     var message = new MandrillMessage();
     message.Subject = "New lead";
     message.FromEmail = "*****@*****.**";
     message.AddTo("*****@*****.**");
     message.ReplyTo = "*****@*****.**";
     //supports merge var content as string
     message.AddGlobalMergeVars("Name", model.Name);
     message.AddGlobalMergeVars("LeadStatus", model.LeadStatus.ToString());
     message.AddGlobalMergeVars("DateCreated", model.DateCreated.ToShortDateString());
     message.AddGlobalMergeVars("DateUpdated", model.DateUpdated.ToShortDateString());
     message.AddGlobalMergeVars("EMAIL", model.Email);
     message.AddGlobalMergeVars("Skype", model.Skype);
     message.AddGlobalMergeVars("Phone", model.Phone);
     message.AddGlobalMergeVars("Company", model.Company);
     message.AddGlobalMergeVars("Skype", model.Skype);
     message.AddGlobalMergeVars("ProjectDescription", model.ProjectDescription);
     message.AddGlobalMergeVars("ProjectStart", model.ProjectStart);
     message.AddGlobalMergeVars("ProjectDeadline", model.ProjectDeadline);
     //template should be created
     var result = api.Messages.SendTemplate(message, "jarboo-new-lead");
 }
Ejemplo n.º 30
0
 public MandrillWhitelistsApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 31
0
 public MandrillTagsApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
 public MandrillExportsApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 33
0
 public MandrillMailer(string key)
 {
     _api = new MandrillApi(key);
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Create a new instance with the given API key
 /// </summary>
 /// <param name="apiKey">The Mandrill API key, e.g. "PmmzuovUZMPJsa73o3jjCw"</param>
 public MandrillMailSender(string apiKey)
 {
     _mandrillClient = new MandrillApi(apiKey);
 }
        //  改用 Mandrill Webhook
        private void UpdateSendMailStatus()
        {
            string MandrillAPIKey = string.Empty;
            List<UDT.MandrillAPIKey> MandrillAPIKeys = Access.Select<UDT.MandrillAPIKey>();
            if (MandrillAPIKeys.Count > 0)
                MandrillAPIKey = MandrillAPIKeys.ElementAt(0).APIKey;
            else
                return;

            MandrillApi mandrill = new MandrillApi(MandrillAPIKey, false);

            string pong = string.Empty;

            try
            {
                pong = mandrill.Ping();
            }
            catch (Exception ex)
            {
                return;
            }
            if (!pong.ToUpper().Contains("PONG!"))
            {
                return;
            }

            string SQL = "select * from $ischool.emba.mail_log where (status ilike 'Sent' or status ilike 'Queued') and ((time_stamp + '7'<update_status_time) or update_status_time is null)";

            DataTable dataTable = Query.Select(SQL);
            foreach (DataRow x in dataTable.Rows)
            {
                string Result = x["result"] + "";
                if (Result.StartsWith("![CDATA["))
                    Result = Result.Replace("![CDATA[", "");
                if (Result.EndsWith("]]"))
                    Result = Result.Replace("]]", "");

                XElement xElement = XElement.Parse(Result, LoadOptions.None);
                if (xElement.Descendants("ResultID") != null)
                {
                    string ResultID = xElement.Descendants("ResultID").ElementAt(0).Value;
                    Info info = new Info();
                    info.id = ResultID;
                    dynamic result = mandrill.SendInfoMessageSync(info);

                    List<UDT.MailLog> MailLogs = Access.Select<UDT.MailLog>(new List<string>() { x["uid"] + "" });
                    MailLogs.ElementAt(0).UpdateStatusTime = DateTime.Now;
                    if ((x["status"] + "").ToLower() != ((string)result.state).ToLower())
                    {
                        MailLogs.ElementAt(0).Status = result.state + "";
                    }
                    MailLogs.SaveAll();
                }
            }
        }
Ejemplo n.º 36
0
 public MandrillInboundApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
 public MandrillSubaccountsApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 38
0
 public MandrillExportsApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 39
0
        public ActionResult SendInvitation(InvitationModel model)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand("insert into emailtofriends(name, email, message) values (@name, @email, @message)", connection);
                command.Parameters.AddWithValue("name", model.Name);
                command.Parameters.AddWithValue("email", model.Email);
                command.Parameters.AddWithValue("message", model.Message);

                try
                {
                    command.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    // do what?

                }
                finally
                {
                    connection.Close();
                }

                //Send mandril message
                try
                {
                    MandrillApi api = new MandrillApi(ProjectConfiguration.MandrillApiKey);
                    var emailMessage = new EmailMessage()
                    {
                        To = new List<EmailAddress>() { new EmailAddress(model.Email, "Invited") },
                        FromEmail = ProjectConfiguration.FromEmail,
                        FromName = ProjectConfiguration.FromName,
                        Subject = string.Format(ProjectConfiguration.InvitationEmailSubject, model.Name),
                        Merge = true,
                        MergeLanguage = "mailchimp"
                    };

                    emailMessage.AddGlobalVariable("invitername", model.Name);
                    emailMessage.AddGlobalVariable("invitermessage", model.Message.Replace("\n", "<br />"));

                    var request = new SendMessageTemplateRequest(emailMessage, "invitation", null);
                    var result = api.SendMessageTemplate(request);
                }
                catch (Exception ex)
                {
                    // do what?
                }

                return new EmptyResult();
            }
        }
 public MandrillSubaccountsApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 41
0
 internal MandrillMessagesApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 42
0
 public MandrillRejectsApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 43
0
 public MandrillInboundApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 44
0
 public void Dispose()
 {
     _mandrillClient = null;
 }
Ejemplo n.º 45
0
 public MandrillSendersApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 46
0
 public MandrillWebHooksApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 47
0
        /// <summary>
        /// SendMailByMandrill
        /// this function is used for sending mail vai Mandrill</summary></summary>
        /// the main parameter is
        /// <add key="host" value="smtp.mandrillapp.com" />
        /// <param name="port"></param>
        /// <add key="port" value="25" />
        /// <param name="from"></param>
        /// <add key="username" value="socioboard"/>
        /// <param name="passsword"></param>
        /// <add key="fromemail" value="*****@*****.**"/>
        /// <param name="to"></param>
        /// <add key="password" value="xyz" />
        /// <param name="bcc"></param>
        /// add key="tomail" value="*****@*****.**" />
        /// its return : EmailResultStatus i.e Sent, Rejected etc.
        /// <param name="cc"></param>
        /// <param name="Host"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="sendgridUserName"></param>
        /// <param name="sendgridPassword"></param>
        /// <returns></returns>

        public string GetStatusFromSendMailByMandrill(string Host, int port, string from, string passsword, string to, string bcc, string cc, string subject, string body, string sendgridUserName, string sendgridPassword)
        {
            string sendMailByMandrill = string.Empty;

            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                //message.from_email = from;
                //message.from_name = from;//"AlexPieter";
                message.from_email = "*****@*****.**";
                message.from_name  = "Socioboard Support";
                message.html       = body;
                message.subject    = subject;
                message.to         = new List <Mandrill.EmailAddress>()
                {
                    new Mandrill.EmailAddress(to)
                };


                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(sendgridPassword, false);


                //List<RejectInfo> ri=mandrillApi.ListRejects();

                var    results = mandrillApi.SendMessage(message);
                string status  = string.Empty;
                foreach (var result in results)
                {
                    try
                    {
                        if (result.Status != Mandrill.EmailResultStatus.Sent)
                        {
                            logger.Error(result.Email + " " + result.RejectReason);
                        }

                        if (Mandrill.EmailResultStatus.Sent == result.Status)
                        {
                            status = Mandrill.EmailResultStatus.Sent.ToString();
                        }
                        else if (Mandrill.EmailResultStatus.Invalid == result.Status)
                        {
                            status = Mandrill.EmailResultStatus.Invalid.ToString();
                        }
                        else if (Mandrill.EmailResultStatus.Queued == result.Status)
                        {
                            status = Mandrill.EmailResultStatus.Queued.ToString();
                        }
                        else if (Mandrill.EmailResultStatus.Rejected == result.Status)
                        {
                            status = Mandrill.EmailResultStatus.Rejected.ToString();
                        }
                        else if (Mandrill.EmailResultStatus.Scheduled == result.Status)
                        {
                            status = Mandrill.EmailResultStatus.Scheduled.ToString();
                        }
                        else
                        {
                            status = result.RejectReason;
                        }
                        //status = Mandrill.EmailResultStatus;
                        //  LogManager.Current.LogError(result.Email, "", "", "", null, string.Format("Email failed to send: {0}", result.RejectReason));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        logger.Error(ex.Message);
                        sendMailByMandrill = ex.Message;
                    }
                }

                sendMailByMandrill = status;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
                sendMailByMandrill = ex.Message;
            }

            return(sendMailByMandrill);
        }
Ejemplo n.º 48
0
 public MandrillWhitelistsApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 49
0
        public string SendDemoMailByMandrill(string Host, int port, string from, string passsword, string to, string bcc, string cc, string subject, string body, string sendgridUserName, string sendgridPassword)
        {
            string sendMailByMandrill = string.Empty;

            try
            {
                Mandrill.EmailMessage message = new Mandrill.EmailMessage();
                message.from_email = from;
                message.from_name  = sendgridUserName;
                message.html       = body;
                message.subject    = subject;
                message.to         = new List <Mandrill.EmailAddress>()
                {
                    new Mandrill.EmailAddress(to)
                };
                Mandrill.MandrillApi mandrillApi = new Mandrill.MandrillApi(sendgridPassword, false);
                var    results      = mandrillApi.SendMessage(message);
                string status       = string.Empty;
                string replysubject = string.Empty;
                string replybody    = string.Empty;
                foreach (var result in results)
                {
                    if (result.Status == Mandrill.EmailResultStatus.Sent || result.Status == Mandrill.EmailResultStatus.Queued)
                    {
                        replysubject = "Request Rcieved";
                        replybody    = "Hello there,</br>We have received your request for a demo. </br>Our Support team will connect to you in time.</br>Warm regards,<p>Best regards,<br/><br />" +
                                       "Support Team<br/>Socioboard Technologies Pvt. Ltd.<br /><br /><a href=\"http://www.socioboard.com\"><img src=\"http://i739.photobucket.com/albums/xx33/Alan_Wilson3526/logo-txt2_zpsc7861ad5.png\" alt=\"\"></a></p>" +
                                       "<p style=\"font-family:Calibri(Body); font-size:12px;.\"><b>Mumbai Office:</b> Unit 206, Shri Krishna Building,Lokhandwala, Andheri West,Mumbai 400053India </br>" +
                                       "<b>Phone:</b> +91-90090-23807, <b>Skype:</b> socioboard.support </br>Socioboard Enterprise and SaaS Versions: <a href=\"http://www.socioboard.com\">http://www.socioboard.com<br /></a> Socioboard Community Version: <a href=\"http://www.socioboard.org\">http://www.socioboard.org</a><br>" +
                                       "</p><table><tr><td><a href=\"https://www.facebook.com/SocioBoard\" target=\"_blank\"><img src=\"http://i739.photobucket.com/albums/xx33/Alan_Wilson3526/facebook-48_zps62d89d59.png\" alt=”Facebook” width=”35? height=”35? border=0></a></td>" +
                                       "<td><a href=\"https://plus.google.com/s/socioboard\" target=\"_blank\"><img src=\"http://i739.photobucket.com/albums/xx33/Alan_Wilson3526/googleplus-30_zps62d89d59.png\" alt=\"G+\"width=”35? height=”35? border=0></a></td>" +
                                       "<td><a href=\"http://www.linkedin.com/company/socioboard\" target=\"_blank\"><img src=\"http://i739.photobucket.com/albums/xx33/Alan_Wilson3526/linkedin-48_zpsceb0f4e2.png\" alt=”LinkedIn” width=”35? height=”35? border=0></a></td>" +
                                       "<td><a href=\"https://twitter.com/Socioboard\" target=\"_blank\"><img src=\"http://i739.photobucket.com/albums/xx33/Alan_Wilson3526/twitter-48_zps57c64c90.png\" alt=”Twitter” width=”35? height=”35? border=0></a></td>" +
                                       "</tr></table>";
                    }
                    else
                    {
                        logger.Error(result.Email + " " + result.RejectReason);
                        replysubject = "Request Not Recieved";
                        replybody    = "Hi there,</br>Oops!!</br>Apparently there was some error and we couldn’t receive your resume.</br>Please try again." +
                                       "<p>Best regards,<br />Support Team<br/>Socioboard Technologies Pvt. Ltd.<br /><a href=\"http://www.socioboard.com\"><img src=\"http://i739.photobucket.com/albums/xx33/Alan_Wilson3526/logo-txt2_zpsc7861ad5.png\" alt=\"\"></a>" +
                                       "<br/></p><p style=\"font-family:Calibri(Body); font-size:12px;\"><b>Bangalore Office:</b> L V Complex, 2nd Floor, No.58, 7th Block, 80 Feet Road, Koramangala, Bangalore-560095</br>" +
                                       "Karnataka, India</br><b><br />Phone:</b> +91-90090-23807, <b>Skype:</b> socioboard.support </br><br />Socioboard Enterprise and SaaS Versions: <a href=\"http://www.socioboard.com\">http://www.socioboard.com<br />" +
                                       "</a>  Socioboard Community Version: <a href=\"http://www.socioboard.org\">http://www.socioboard.org</a><br></p><table><tr>" +
                                       "<td><a href=\"https://www.facebook.com/SocioBoard\" target=\"_blank\"><img src=\"http://i739.photobucket.com/albums/xx33/Alan_Wilson3526/facebook-48_zps62d89d59.png\" alt=”Facebook” width=”35? height=”35? border=0></a></td>" +
                                       "<td><a href=\"https://plus.google.com/s/socioboard\" target=\"_blank\"><img src=\"http://i739.photobucket.com/albums/xx33/Alan_Wilson3526/googleplus-30_zps62d89d59.png\" alt=\"G+\"width=”35? height=”35? border=0></a></td>" +
                                       "<td><a href=\"http://www.linkedin.com/company/socioboard\" target=\"_blank\"><img src=\"http://i739.photobucket.com/albums/xx33/Alan_Wilson3526/linkedin-48_zpsceb0f4e2.png\" alt=”LinkedIn” width=”35? height=”35? border=0></a></td>" +
                                       "<td><a href=\"https://twitter.com/Socioboard\" target=\"_blank\"><img src=\"http://i739.photobucket.com/albums/xx33/Alan_Wilson3526/twitter-48_zps57c64c90.png\" alt=”Twitter” width=”35? height=”35? border=0></a></td>" +
                                       "</tr></table>";
                    }
                    string rtn = ReplyForCareerMail(to, replybody, replysubject, from, sendgridPassword);
                }

                sendMailByMandrill = "Success";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);

                sendMailByMandrill = ex.Message;
            }

            return(sendMailByMandrill);
        }
Ejemplo n.º 50
0
 public MandrillUsersApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 51
0
 internal MandrillTemplatesApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 52
0
 public MandrillUsersApi(MandrillApi mandrillApi)
 {
     MandrillApi = mandrillApi;
 }
Ejemplo n.º 53
0
        public static void SendProgressBill(List <M.EmailAddress> argToAddress, string argCompany, string argProject, string argFlatNo, decimal argCurrentAmount, decimal argCurrentNetAmount, decimal argGross, decimal argNetAmount, decimal argPaidAmount, DataTable argdt)
        {
            try
            {
                //string activationLink = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Register/Activation.aspx?id=" + "";

                Cursor.Current = Cursors.WaitCursor;

                DataTable dt = new DataTable();
                dt = CommFun.GetMandrillSetting(1);
                if (dt == null)
                {
                    return;
                }
                if (dt.Rows.Count == 0)
                {
                    return;
                }

                string sFromName     = CommFun.IsNullCheck(dt.Rows[0]["FromName"], CommFun.datatypes.vartypestring).ToString();
                string sUserId       = CommFun.IsNullCheck(dt.Rows[0]["UserId"], CommFun.datatypes.vartypestring).ToString();
                string sKeyId        = CommFun.IsNullCheck(dt.Rows[0]["KeyId"], CommFun.datatypes.vartypestring).ToString();
                string sTemplateName = CommFun.IsNullCheck(dt.Rows[0]["TemplateId"], CommFun.datatypes.vartypestring).ToString();

                M.MandrillApi api = new M.MandrillApi(sKeyId, true);

                M.EmailMessage emailmsg = new M.EmailMessage();
                emailmsg.from_name    = sFromName;
                emailmsg.from_email   = sUserId;
                emailmsg.to           = argToAddress;
                emailmsg.attachments  = null;
                emailmsg.merge        = true;
                emailmsg.track_opens  = true;
                emailmsg.track_clicks = true;
                emailmsg.important    = true;

                emailmsg.AddGlobalVariable("Company", argCompany);
                emailmsg.AddGlobalVariable("Project", argProject);
                emailmsg.AddGlobalVariable("FlatNo", argFlatNo);
                emailmsg.AddGlobalVariable("PaidAmount", argPaidAmount.ToString("n2"));
                emailmsg.AddGlobalVariable("Balance", (argNetAmount - argPaidAmount).ToString("n2"));

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<table border='1' cellpadding='0' cellspacing='0'>");
                if (argdt != null)
                {
                    sb.Append("<tr>");
                    foreach (DataColumn column in argdt.Columns)
                    {
                        sb.AppendFormat("<td>{0}</td>", HttpUtility.HtmlEncode(column.ColumnName));
                    }
                    sb.Append("</tr>");

                    foreach (DataRow row in argdt.Rows)
                    {
                        sb.Append("<tr>");
                        foreach (DataColumn column in argdt.Columns)
                        {
                            sb.AppendFormat("<td>{0}</td>", HttpUtility.HtmlEncode(row[column]));
                        }
                        sb.Append("</tr>");
                    }
                }
                sb.AppendLine("</table>");

                emailmsg.AddGlobalVariable("StageDetails", sb.ToString());

                List <M.TemplateContent> tempContent = new List <M.TemplateContent>();
                tempContent.Add(new M.TemplateContent()
                {
                    name = sTemplateName
                });

                List <M.EmailResult> errorMsg = api.SendMessage(emailmsg, sTemplateName, tempContent);

                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }