Beispiel #1
0
        public string SendEmailTemplate(EmailTemplateNames templateName, Dictionary <string, string> tokens, string sendToEmail, DataModel.Store store)
        {
            //string storeEmail = storeContext.CurrentStore.GetSetting(StoreSettingNames.OrderCompletedEmailRecipient);
            string storeEmail           = store.GetSetting(StoreSettingNames.OrderCompletedEmailRecipient);
            string customerServiceEmail = store.GetSetting(StoreSettingNames.CustomerServiceEmailAddress);
            string hostEmail            = HostSettings.GetHostSetting("HostEmail");
            string from = !string.IsNullOrEmpty(customerServiceEmail) ? customerServiceEmail : hostEmail;

            vStoreEmailTemplate emailTemplate = store.GetStoreEmailTemplate(templateName);

            string subject = tokenizer.ReplaceTokensInString(HttpUtility.HtmlDecode(emailTemplate.SubjectTemplate), tokens);
            string body    = tokenizer.ReplaceTokensInString(HttpUtility.HtmlDecode(emailTemplate.BodyTemplate), tokens);

            body = InjectEmailCssIntoBody(body);

            return(SendEmail(from, sendToEmail, subject, body, true));
        }
        protected void btnEmailCustomer_Click(object sender, EventArgs e)
        {
            if (LoadOrder())
            {
                TokenHelper tokenHelper = new TokenHelper(StoreContext);
                var         tokens      = tokenHelper.GetOrderTokens(order, true);

                var tokenizer = new TokenProcessor(Constants.TemplateTokenStart, Constants.TemplateTokenEnd);
                vStoreEmailTemplate emailTemplate = StoreContext.CurrentStore.GetStoreEmailTemplate(EmailTemplateNames.OrderReceived);
                string body = tokenizer.ReplaceTokensInString(HttpUtility.HtmlDecode(emailTemplate.BodyTemplate), tokens);

                Session["from"] = StoreContext.CurrentStore.GetSetting(StoreSettingNames.CustomerServiceEmailAddress);
                Session["to"]   = order.CustomerEmail;
                Session["body"] = body;

                Response.Redirect(StoreUrls.Admin(ModuleDefs.Admin.Views.SendCustomerEmail));
            }
        }