Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Sep 17, 2015 @ 09:08
    Rasmus Fjord
    0

    Sending email from codebehind and changing subject

    Hey there :)

    Im using this to send a mail from codebehind:

    EmailTemplateService.Instance.Get(1, 3).Send(order);
    

    It works great but if i want to add something to the subject of the mail, can i do that ? The customer wants the orderid to be there.

  • Anders Burla 2560 posts 8256 karma points
    Sep 17, 2015 @ 09:09
    Anders Burla
    100

    Hook into the EmailSending event :)

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Sep 17, 2015 @ 09:47
    Rasmus Fjord
    1

    Arh awesome :)

    For others on same position i made a class like this :

    using System.Reflection;
    using TeaCommerce.Api.Models;
    using TeaCommerce.Api.Notifications;
    using Umbraco.Core;
    
    namespace MyProject.Web.EventHandler
    {
        public class TcEmailHandler  :ApplicationEventHandler
        {
    
             public TcEmailHandler()
            {
                NotificationCenter.EmailTemplate.MailSending += Mail_Sending;
    
            }
    
             private void Mail_Sending(EmailTemplate emailTemplate, MailSendingEventArgs e)
             {
                 e.MailMessage.Subject = e.MailMessage.Subject + " #" + e.Order.Properties["CustomIdProp"];
             }
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft