Create a custom message type class

Abstract

The EXM module lets developers create and use custom message types, which also require a custom type resolver.

The Email Experience Manager module 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:

  1. Derive a custom message type class from either the MessageItem class or one of its descendants:

    • The TextMail class

    • The HtmlMail class

    • The WebPageMail class

    • The ABTestMessage class

  2. Define a message template for the new message type.

  3. Implement the Clone() method on your custom type, even when it does not derive from the message Item class.

  4. Derive a custom type resolver class from the TypeResolver class.

  5. Override the GetCorrectMessageObject method in the class that you derived from the TypeResolver class.

Example:

public 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);
  }
...
}