public void SendOrderEmail(Order order, MailerType mailType) {
            //pull the mailer
            Mailer mailer = GetMailerForOrder(order, mailType);

            //no catches here - let bubble to caller
            Send(mailer);
        }
Example #2
0
 public Mailer(MailerType mailType, string email, string userName, 
     string subject, string body, bool isHtml) {
     MailType = mailType;
     ToEmailAddress = email;
     UserName = userName;
     Subject = subject;
     Body = body;
     IsHtml = isHtml;
 }
        public Mailer GetMailer(MailerType mailType, string languageCode) {
            int mailerID = (int)mailType;
            Mailer result = _mailerRepository.GetMailerTemplates(languageCode).Where(x => x.ID == mailerID).SingleOrDefault();
            if (result == null)
                throw new InvalidOperationException("There is no mailer template for this language/template selection");

            return result;


        }
        public Mailer GetMailerForOrder(Order order, MailerType mailType) {
            //pull the template
            Mailer mailer = GetMailer(mailType, order.UserLanguageCode);


            //format it
            //this will change, for sure
            //need some better injection method
            string storeName=System.Configuration.ConfigurationManager.AppSettings["StoreName"].ToString();
            string storeReplyTo=System.Configuration.ConfigurationManager.AppSettings["StoreEmail"].ToString();
            
            mailer.Body = mailer.Body.Replace("#STORENAME#", storeName)
                .Replace("#USERNAME#",order.ShippingAddress.FullName)
                .Replace("#ORDERLINK#",System.IO.Path.Combine(_orderAbsoluteRoot,order.ID.ToString()));

            mailer.FromEmailAddress = storeReplyTo;
            mailer.ToEmailAddress = order.ShippingAddress.Email;
            mailer.UserName = order.UserName;
            mailer.Status = MailerStatus.Queued;

            return mailer;
        }
 public Mailer GetMailer(MailerType mailType) {
     
     //default to English... or your favorite...
     return GetMailer(mailType, "en");
 }  
 public Mailer GetMailer(MailerType mailType) {
     return GetMailer(mailType, "");
 }
        public Mailer GetMailer(MailerType mailType, string languageCode) {
            return new Mailer(mailType, "*****@*****.**", "testuser", "subject", "testbody #STORENAME# #USERNAME# #ORDERLINK#",false);

        }