Creating a custom message type class
The Email Experience Manager component lets developers create and use custom types of message items. The default EXM message types are mapped to the appropriate class in the code by the TypeResolver class. To use a custom message type class, you must also create a custom type resolver to map your message type correctly.
To create a custom message type class:
-
Derive a custom message type class from either the
MessageItemclass or one of its descendants:-
The
TextMailclass -
The
HtmlMailclass -
The
WebPageMailclass -
The
ABTestMessageclass
-
-
Define a message template for the new message type.
-
Override the
Clone()method on your custom message type class or it will fail during dispatch. -
Derive a custom type resolver class from the
Sitecore.Modules.EmailCampaign.Core.TypeResolverclass. -
In the Sitecore.EmailExperience.Core.config file, patch the
exm/typeResolversetting with your custom type resolver. -
Override the
GetCorrectMessageObjectmethod in the class that you derived from theTypeResolverclass.Example:
RequestResponsepublic class NewMail : MessageItem { public static bool IsCorrectMessageItem(Item item) { return ItemUtilExt.IsTemplateDescendant(item, TemplateIds.NewMessageTemplate); } ... } public class NewTypeResolver : TypeResolver { public override MessageItem GetCorrectMessageObject(Item item) { var result = NewMail.FromItem(item); return result != null ? result : base.GetCorrectMessageObject(item); } ... }