Exemplo n.º 1
0
        public System.Net.Mail.MailMessage PreviewMessage(Content.HtmlTemplate t, MerchantTribeApplication app)
        {
            System.Net.Mail.MailMessage result = new System.Net.Mail.MailMessage();

            if (this.Members.Count > 0)
            {
                if (t != null)
                {
                    Content.HtmlTemplate copy = t.ReplaceTagsInTemplate(app, this.Members[0]);
                    result = copy.ConvertToMailMessage(this.Members[0].EmailAddress);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public override bool Execute(OrderTaskContext context)
        {
            string EmailSelection = string.Empty;

            EmailSelection = _ToEmail;
            string toEmail = string.Empty;

            switch (EmailSelection)
            {
            case "Admin":
                toEmail = context.MTApp.CurrentRequestContext.CurrentStore.Settings.MailServer.EmailForNewOrder;
                break;

            case "Customer":
                toEmail = context.Order.UserEmail;
                break;

            default:
                toEmail        = context.Order.UserEmail;
                EmailSelection = "Customer";
                break;
            }

            try {
                if (toEmail.Trim().Length > 0)
                {
                    Content.HtmlTemplate t = context.MTApp.ContentServices.GetHtmlTemplateOrDefault(Content.HtmlTemplateType.OrderShipment);
                    t = t.ReplaceTagsInTemplate(context.MTApp, context.Order, context.Order.PackagesAsReplaceable());

                    System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage();
                    m = t.ConvertToMailMessage(toEmail);
                    if (m != null)
                    {
                        Utilities.MailServices.SendMail(m, context.MTApp.CurrentStore);
                    }
                }
            }
            catch (Exception ex) {
                EventLog.LogEvent(ex);
            }

            return(true);
        }
Exemplo n.º 3
0
 // Mailing List Send Functions
 public void SendToList(Content.HtmlTemplate t, bool sendAsync, MerchantTribeApplication app)
 {
     if (t != null)
     {
         foreach (MailingListMember m in this.Members)
         {
             try {
                 Content.HtmlTemplate        copy = t.ReplaceTagsInTemplate(app, m);
                 System.Net.Mail.MailMessage msg  = new System.Net.Mail.MailMessage();
                 msg = copy.ConvertToMailMessage(m.EmailAddress);
                 if (msg != null)
                 {
                     Utilities.MailServices.SendMail(msg, app.CurrentStore);
                 }
             }
             catch (Exception ex) {
                 EventLog.LogEvent(ex);
             }
         }
     }
 }
Exemplo n.º 4
0
        private bool SendEmail(MerchantTribeApplication app, Contacts.VendorManufacturer vendorOrManufacturer, Orders.Order order)
        {
            string toEmail = vendorOrManufacturer.EmailAddress;

            Content.HtmlTemplate t = null;
            string templateBvin    = vendorOrManufacturer.DropShipEmailTemplateId;

            if (templateBvin != string.Empty)
            {
                long templateId = 0;
                long.TryParse(templateBvin, out templateId);
                t = app.ContentServices.HtmlTemplates.Find(templateId);
            }
            if (t == null)
            {
                t = app.ContentServices.GetHtmlTemplateOrDefault(Content.HtmlTemplateType.DropShippingNotice);
            }

            if (toEmail.Trim().Length > 0)
            {
                List <Content.IReplaceable> replacers = new List <Content.IReplaceable>();
                replacers.Add(order);
                replacers.Add(vendorOrManufacturer);
                t = t.ReplaceTagsInTemplate(app, replacers, order.ItemsAsReplaceable());

                System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage();
                if (vendorOrManufacturer != null)
                {
                    m = t.ConvertToMailMessage(toEmail);
                }
                if (m != null)
                {
                    return(Utilities.MailServices.SendMail(m));
                }
            }
            return(false);
        }