Hi,
We have a website with multiple languagelayers. Where we want to send out emailmarketing from.
On the recipient users we store their preferred language.
When sending out the emails it only sends out the original selected language of the email page.
But we want to send the translated version of the page to the recipient based on there preferred language.
We've created an notification subscriber for "OnBeforeMerging" to change the page before sending to user.
We can get the translated body for the message, but when we update the HtmlBody of the message it still sends out the original email body.
Are we missing something? Or is there a different way to change the body of email send?
[Subscribe(Notifications.OnBeforeMerging)] public class OnBeforeMergingSubscriber : NotificationSubscriber { public override void OnNotify(string notification, NotificationArgs args) { if (!(args is Notifications.OnBeforeMergingNotificationArgs mergingArgs)) { return; } var email = Dynamicweb.EmailMarketing.Email.GetEmailByMessageId(mergingArgs.Message.Id); var userLanguage = mergingArgs.Recipient.TagValueCollection["Email:User.AccessUser_LanguageCode"]?.ToString(); if (email.Page.Area.Culture != userLanguage) { var preferedLangaugePage = email.Page.Languages.FirstOrDefault(x => x.Area.Culture == userLanguage)); if (preferedLangaugePage != null) { var recipientContext = email.RecipientProvider.GetRecipientContentContext(mergingArgs.Recipient); var translatedBody = Renderer.BuildPageHtml(preferedLangaugePage.ID, email.Template, recipientContext); mergingArgs.Message.HtmlBody = translatedBody; mergingArgs.Message.Save(); } } } }