public void TaskResponsibleChanged(TaskResponsibleChangedData data)
        {
            if (!_setting.UseMandrill)
            {
                return;
            }

            var message = new EmailMessage
            {
                to = new[] { new EmailAddress(data.EmployeeEmail) },
                from_email = _setting.MandrillFrom,
                subject = _setting.MandrillTaskResponsibleChangedNotificationSubject
            };

            message.AddGlobalVariable("TASKNAME", data.TaskTitle);
            message.AddGlobalVariable("TASKROLE", data.Role);

            _api.SendMessage(message, _setting.MandrillTaskResponsibleNotificationTemplate, null);
        }
        private void CreateAndSendEmailMessageFromTemplate(WebHookEvent evt)
        {
            var metadata = ParseMetadataFromMandrill(evt);
            var message  = new Mandrill.EmailMessage();

            message.to = new List <Mandrill.EmailAddress>()
            {
                new EmailAddress {
                    email = "*****@*****.**"
                },
                new EmailAddress {
                    email = "*****@*****.**"
                }
            };

            message.subject    = String.Format("Bounced email notification", evt.Event);
            message.from_email = "*****@*****.**";


            if (metadata.ContainsKey("CustID"))
            {
                message.AddGlobalVariable("customerID", metadata["CustID"].ToUpper());
            }
            else
            {
                message.AddGlobalVariable("customerID", "Unknown");
            }
            message.AddGlobalVariable("bouncedEmailAddress", evt.Msg.Email);
            message.AddGlobalVariable("application", GetSendingApplicationName(evt));
            message.AddGlobalVariable("timesent", TimeZoneInfo.ConvertTimeFromUtc(evt.Msg.TimeStamp, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")).ToString());

            _mandrillApi.SendMessage(message, "mandrill-email-bounce", null);
        }
Beispiel #3
0
        public static void SendBulkMail(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=" + argFromAddress;

                Cursor.Current = Cursors.WaitCursor;

                DataTable dt = new DataTable();
                dt = CommFun.GetMandrillSetting(3);
                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);

                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);
            }
        }
        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);
            }
        }
Beispiel #5
0
        public String EmailRequestBalance(String masterEmail, String sellerName, String masterName)
        {
            string result = "error";

            try
            {
                UserInfo user = new UserInfo();
                Mandrill.Models.TemplateInfo template = apimd.TemplateInfo("Solicitud_vendedor_a_master");
                Mandrill.EmailMessage        msg      = new Mandrill.EmailMessage
                {
                    from_email = "*****@*****.**"
                    ,
                    from_name = "YoVendoRecarga.com"
                    ,
                    auto_text = false
                    ,
                    subject = "Solicitud de saldo"
                    ,
                    to = new List <Mandrill.EmailAddress> {
                        new Mandrill.EmailAddress(masterEmail, masterName, "to")
                    }
                    ,
                    bcc_address = "*****@*****.**"
                    ,
                    merge_language = "mailchimp"
                    ,
                    merge = true
                };
                msg.AddGlobalVariable("NAME", sellerName);
                msg.AddGlobalVariable("USER", masterName);
                msg.AddGlobalVariable("LINK", "https://yovendorecarga.com/SV/Account/LogIn");
                apimd.SendMessage(msg, template.name, null);
                result = "exito";
            }
            catch (Exception)
            {
                result = "error";
                throw;
            }

            return(result);
        }
Beispiel #6
0
        public String EmailUserProfile100(String email, String name, String code)
        {
            string result = "error";

            try
            {
                UserInfo user = new UserInfo();
                Mandrill.Models.TemplateInfo template = apimd.TemplateInfo("Saldo_aplicado_exitosamente ");
                Mandrill.EmailMessage        msg      = new Mandrill.EmailMessage
                {
                    from_email = "*****@*****.**"
                    ,
                    from_name = "YoVendoRecarga.com"
                    ,
                    auto_text = false
                    ,
                    subject = "Saldo Aplicado"
                    ,
                    to = new List <Mandrill.EmailAddress> {
                        new Mandrill.EmailAddress(email, name, "to")
                    }
                    ,
                    bcc_address = "*****@*****.**"
                    ,
                    merge_language = "mailchimp"
                    ,
                    merge = true
                };
                msg.AddGlobalVariable("NAME", name);
                msg.AddGlobalVariable("CODE", code);
                msg.AddGlobalVariable("EMAIL", email);
                apimd.SendMessage(msg, template.name, null);
                result = "exito";
            }
            catch (Exception)
            {
                result = "error";
                throw;
            }

            return(result);
        }
Beispiel #7
0
        public String EmailRestorePassword(String email, String url, String name)
        {
            string result = "error";

            try
            {
                UserInfo user = new UserInfo();
                Mandrill.Models.TemplateInfo template = apimd.TemplateInfo("Restablecer_contraseña");
                Mandrill.EmailMessage        msg      = new Mandrill.EmailMessage
                {
                    from_email = "*****@*****.**"
                    ,
                    from_name = "YoVendoRecarga.com"
                    ,
                    auto_text = false
                    ,
                    subject = "Reestablecer Contraseña"
                    ,
                    to = new List <Mandrill.EmailAddress> {
                        new Mandrill.EmailAddress(email, name, "to")
                    }
                    ,
                    bcc_address = "*****@*****.**"
                    ,
                    merge_language = "mailchimp"
                    ,
                    merge = true
                };
                msg.AddGlobalVariable("NAME", name);
                msg.AddGlobalVariable("LINK", url);

                apimd.SendMessage(msg, template.name, null);
            }
            catch (Exception)
            {
                result = "error";
                throw;
            }

            return(result);
        }
        public void NewTask(NewTaskData data)
        {
            if (!_setting.UseMandrill)
            {
                return;
            }

            var message = new EmailMessage
            {
                to = new[] { new EmailAddress(_setting.JarbooInfoEmail) },
                from_email = _setting.MandrillFrom,
                subject = "New task"
            };

            message.AddGlobalVariable("CUSTOMERNAME", data.CustomerName);
            message.AddGlobalVariable("TASKNAME", data.TaskTitle);
            message.AddGlobalVariable("PROJECTNAME", data.ProjectName);
            message.AddGlobalVariable("TASKDESCRIPTION", data.TaskDescription);
            message.AddGlobalVariable("TASKLINK", _urlConstructor.TaskView(data.TaskId));

            _api.SendMessage(message, _setting.MandrillNewTaskTemplate, null);
        }
        public void SendPasswordRecoveryEmail(string email, string link)
        {
            if (!_setting.UseMandrill)
            {
                return;
            }

            var message = new EmailMessage
            {
                to = new[] { new EmailAddress(email) },
                from_email = _setting.MandrillFrom,
                subject = "Jarbo password recovery"
            };

            message.AddGlobalVariable("QUESTIONLINK", link);

            _api.SendMessage(message, _setting.MandrillPasswordRecoveryTemplate, null);
        }
Beispiel #10
0
        public String EmailNewLogin(String name, String email, String deviceInfo, DateTime dateLogin, String deviceIP)
        {
            string result = "error";

            try
            {
                UserInfo user = new UserInfo();
                Mandrill.Models.TemplateInfo template = apimd.TemplateInfo("multiples_dispositivos");
                Mandrill.EmailMessage        msg      = new Mandrill.EmailMessage
                {
                    from_email = "*****@*****.**"
                    ,
                    from_name = "YoVendoRecarga.com"
                    ,
                    auto_text = false
                    ,
                    subject = "Nuevo Inicio de Sesión"
                    ,
                    to = new List <Mandrill.EmailAddress> {
                        new Mandrill.EmailAddress(email, name, "to")
                    }
                    ,
                    bcc_address = "*****@*****.**"
                    ,
                    merge_language = "mailchimp"
                    ,
                    merge = true
                };

                msg.AddGlobalVariable("NAME", name);
                msg.AddGlobalVariable("EMAIL", email);
                msg.AddGlobalVariable("MODELO", deviceInfo);
                msg.AddGlobalVariable("DATE", dateLogin.ToString("dd/MM/yy"));
                msg.AddGlobalVariable("TIME", dateLogin.ToString("hh:mm:ss tt"));
                msg.AddGlobalVariable("ADDRESS", deviceIP);

                apimd.SendMessage(msg, template.name, null);
                result = "success";
            }
            catch (Exception)
            {
                result = "error";
                throw;
            }

            return(result);
        }
Beispiel #11
0
        public String EmailTransferConfirmationReceived(String pUserEmail, String pNameDepositor, String pReferenceNumber, String pBank, String pAmount, String pUserNames, String pDate)
        {
            string result = "error";

            try
            {
                UserInfo user = new UserInfo();
                Mandrill.Models.TemplateInfo template = apimd.TemplateInfo("Confirmación_transferencia_recibida");
                Mandrill.EmailMessage        msg      = new Mandrill.EmailMessage
                {
                    from_email = "*****@*****.**"
                    ,
                    from_name = "YoVendoRecarga.com"
                    ,
                    auto_text = false
                    ,
                    subject = "Transferencia YoVendoRecarga"
                    ,
                    to = new List <Mandrill.EmailAddress> {
                        new Mandrill.EmailAddress(pUserEmail, pUserNames, "to")
                    }
                    ,
                    bcc_address = "*****@*****.**"
                    ,
                    merge_language = "mailchimp"
                    ,
                    merge = true
                };
                msg.AddGlobalVariable("NUMBER", pReferenceNumber);
                msg.AddGlobalVariable("BANK", pBank);
                msg.AddGlobalVariable("AMOUNT", "$ " + pAmount);
                msg.AddGlobalVariable("DATE", pDate);
                msg.AddGlobalVariable("NAME", pNameDepositor);
                msg.AddGlobalVariable("USER", pUserNames);
                apimd.SendMessage(msg, template.name, null);
            }
            catch (Exception)
            {
                result = "error";
                throw;
            }

            return(result);
        }
Beispiel #12
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);
            }
        }
        private void CreateAndSendEmailMessageFromTemplate(WebHookEvent evt)
        {
            var metadata = ParseMetadataFromMandrill(evt);
            var message = new Mandrill.EmailMessage();

            message.to = new List<Mandrill.EmailAddress>()
                    {
                        new EmailAddress{
                            email = "*****@*****.**"
                        },
                        new EmailAddress{
                            email = "*****@*****.**"
                        }
                    };

            message.subject = String.Format("Bounced email notification", evt.Event);
            message.from_email = "*****@*****.**";

            if (metadata.ContainsKey("CustID"))
                message.AddGlobalVariable("customerID", metadata["CustID"].ToUpper());
            else
                message.AddGlobalVariable("customerID", "Unknown");
            message.AddGlobalVariable("bouncedEmailAddress", evt.Msg.Email);
            message.AddGlobalVariable("application", GetSendingApplicationName(evt));
            message.AddGlobalVariable("timesent", TimeZoneInfo.ConvertTimeFromUtc(evt.Msg.TimeStamp, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")).ToString());

            _mandrillApi.SendMessage(message, "mandrill-email-bounce", null);
        }