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 655 posts 1535 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 Johansen 2560 posts 8256 karma points
    Sep 17, 2015 @ 09:09
    Anders Burla Johansen
    100

    Hook into the EmailSending event :)

  • Rasmus Fjord 655 posts 1535 karma points c-trib
    Sep 17, 2015 @ 09:47
    Rasmus Fjord
    0

    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