Пример #1
0
        public static async Task <String> EnviarContactoAdmin(Contacto contacto)
        {
            var task = api.UserInfoAsync();


            EmailMessage message = new EmailMessage();

            message.subject = "Se ha realizado un nuevo contacto";
            string body = GetContactoTemplate();

            body         = body.Replace("{{EMAIL}}", contacto.Email);
            body         = body.Replace("{{MENSAJE}}", contacto.Mensaje);
            message.html = body;
            EmailAddress        address    = new EmailAddress("*****@*****.**");
            List <EmailAddress> listaEmail = new List <EmailAddress>();

            listaEmail.Add(address);
            message.to        = listaEmail;
            message.from_name = "ClothIt";

            await task.ContinueWith(data =>
            {
                var userInfo       = data.Result;
                message.from_email = userInfo.username;
            });


            List <EmailResult> resultados = await api.SendMessageAsync(message);

            return("Mensaje Enviado");
        }
Пример #2
0
    public static void SendWelcomeEmailv2(string emailAddress, UserProfile user, string userAgent, string db)
    {
        string apiKey = ConfigurationManager.AppSettings["MandrillAPIKey"];

        var api = new MandrillApi(apiKey);

        var recipients = new List <EmailAddress>();

        recipients.Add(new EmailAddress(emailAddress, user.userName));


        var message = new EmailMessage()
        {
            to         = recipients,
            from_email = "*****@*****.**",
            from_name  = "Cult Collection",
            subject    = "Welcome to Cult Collection",
        };

        message.AddGlobalVariable("FNAME", user.userName);

        //Get Hot itema

        /*
         * List<Product> hotItems = Product.GetPopularProductsByUserv2(user.userId, db, 1, 6);
         * for (int i=1; i<= hotItems.Count(); i++)
         * {
         *  message.AddGlobalVariable("II"+i, hotItems[i-1].GetNormalImageUrl());
         *  message.AddGlobalVariable("IN"+i, hotItems[i-1].name);
         *  message.AddGlobalVariable("IB" + i, hotItems[i-1].brandName);
         *  message.AddGlobalVariable("IU" + i, "http://startcult.com/product.html?prodId=" + hotItems[i - 1].id + "&colorId=" + hotItems[i - 1].colors[0].canonical[0]
         + "&catId=" + hotItems[i - 1].categories[0] + "&user=CultCollection&url=" );
         + }
         */

        message.important = true;

        if (userAgent.Contains("iPad"))
        {
            var result = api.SendMessageAsync(message, "Welcome basic – iPad", null);
        }
        else if (userAgent.Contains("iPhone"))
        {
            var result = api.SendMessageAsync(message, "Welcome basic – iPhone", null);
        }

        try
        {
            //SubscribeUserToMailChimp(emailAddress, user.userName);
        }
        catch (Exception) { }
    }
Пример #3
0
        public Task SendAsync(IdentityMessage message)
        {
            var task = _mandrill.SendMessageAsync(new EmailMessage
            {
                from_email = EmailFromAddress,
                from_name  = EmailFromName,
                subject    = message.Subject,
                to         = new List <Mandrill.EmailAddress> {
                    new EmailAddress(message.Destination)
                },
                html = message.Body
            });

            return(task);
        }
Пример #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);
            }
        }
Пример #5
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);
            }
        }
Пример #6
0
    public static void SendOOTDWinnerEmail(UserProfile user, Look look)
    {
        string apiKey = ConfigurationManager.AppSettings["MandrillAPIKey"];

        var api = new MandrillApi(apiKey);

        var recipients = new List <EmailAddress>();

        recipients.Add(new EmailAddress(user.emailId, user.userName));


        var message = new EmailMessage()
        {
            to         = recipients,
            from_email = "*****@*****.**",
            from_name  = "Cult Collection",
            subject    = "You're today's #OOTD winner!",
        };

        message.AddGlobalVariable("FNAME", user.userName);
        message.AddGlobalVariable("LIMG", "http://startcult.com/images/looks/" + look.id + ".jpg");
        message.AddGlobalVariable("LURL", "http://startcult.com/look.html?lookId=" + look.id + "&userName=Cult_OOTD&url=https://s3-us-west-2.amazonaws.com/fkuserpics/163.jpg&utm_source=email&utm_medium=OOTDemail");
        message.AddGlobalVariable("LDESC", look.title);
        message.important = true;

        var result = api.SendMessageAsync(message, "#OOTD Winner", null);
    }
Пример #7
0
    public static void ForgotPasswordEmail(string emailAddress, string userName, string newPassword)
    {
        string apiKey = ConfigurationManager.AppSettings["MandrillAPIKey"];

        var api = new MandrillApi(apiKey);

        var recipients = new List <EmailAddress>();

        recipients.Add(new EmailAddress(emailAddress, userName));


        var message = new EmailMessage()
        {
            to         = recipients,
            from_email = "*****@*****.**",
            from_name  = "Cult Collection",
            subject    = "Cult Collection password reset",
        };

        message.AddGlobalVariable("FNAME", userName);
        message.AddGlobalVariable("TMPPWD", newPassword);
        message.important = true;

        var result = api.SendMessageAsync(message, "Password Reset", null);
    }
Пример #8
0
    public static void SendWelcomeEmail(string emailAddress, string userName)
    {
        string apiKey = ConfigurationManager.AppSettings["MandrillAPIKey"];

        var api = new MandrillApi(apiKey);

        var recipients = new List <EmailAddress>();

        recipients.Add(new EmailAddress(emailAddress, userName));


        var message = new EmailMessage()
        {
            to         = recipients,
            from_email = "*****@*****.**",
            from_name  = "Cult Collection",
            subject    = "Welcome to Cult Collection",
        };

        message.AddGlobalVariable("FNAME", userName);
        message.important = true;

        var result = api.SendMessageAsync(message, "Welcome Email 1st", null);

        try
        {
            SubscribeUserToMailChimp(emailAddress, userName);
        }
        catch (Exception) { }
    }
Пример #9
0
        public async Task <CommonResponse> Send(string recipient, MemoryStream stream)
        {
            var output = new CommonResponse
            {
                Message = "Failed to send PDF to " + recipient,
                Success = false
            };

            try
            {
                var mandrill = new MandrillApi(ConfigurationManager.AppSettings.Get("MandrillApiKey"));

                //Create attachment
                var attachment = new email_attachment()
                {
                    name    = string.Format("Image2PDF_{0}.pdf", DateTime.Now.ToString("MMM-dd-yyyy-hh-mm-ss")),
                    type    = "application/pdf",
                    content = System.Convert.ToBase64String(stream.ToArray())
                };

                //Create email
                var email = new EmailMessage()
                {
                    from_email = "*****@*****.**",
                    from_name  = "Image2PDF",
                    to         = new List <EmailAddress>()
                    {
                        new EmailAddress(recipient)
                    },
                    subject     = "[Image2PDF] Your images have been converted to PDF!",
                    html        = "<p>Thank you for using Image2PDF! Your images have been converted to a PDF document, which you will find attached to this email.</p>",
                    text        = "Thank you for using Image2PDF! Your images have been converted to a PDF document, which you will find attached to this email.",
                    attachments = new List <email_attachment>()
                    {
                        attachment
                    }
                };

                var send = await mandrill.SendMessageAsync(email);

                output.Success = true;
            }
            catch (Exception e)
            {
                output.Message = e.Message;
            }

            return(output);
        }
Пример #10
0
        public virtual async Task <List <IMailResponse> > SendAsync(MailAttributes mailAttributes)
        {
            var mail     = GenerateProspectiveMailMessage(mailAttributes);
            var response = new List <IMailResponse>();

            await _client.SendMessageAsync(mail).ContinueWith(x => response.AddRange(x.Result.Select(result => new MandrillMailResponse
            {
                Email        = result.Email,
                Status       = MandrillMailResponse.GetProspectiveStatus(result.Status.ToString()),
                RejectReason = result.RejectReason,
                Id           = result.Id
            })));

            return(response);
        }