MailSubscriptionHandlerValidateMessage Method Content Studio 5.7 SDK
Content Studio Web Content Management System

[This is preliminary documentation and is subject to change.]

Validates a message before it is sent to a single subscriber.

Namespace: ContentStudio.Document.Subscription.EventHandler
Assembly: CSSubscriptionEventHandler (in CSSubscriptionEventHandler.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

protected override bool ValidateMessage(
	SubscriptionInformation subscriber
)

Parameters

subscriber
Type: ContentStudio.Document.Subscription.EventHandlerSubscriptionInformation
The subscriber.

Return Value

Type: Boolean
true if the message is valid; otherwise, false
Remarks

Developers can override this method when there is a need to alter the message content according to the subscriber found or make sure that the message is suited for the subscriber. This implementation replaces a number of predified strings with standard data for the subsriber (i.e. name, address and subscription key). Custom implementations should call the base class implementation at the end of the code. return base.ValidateMessage(subscriber);. To change the text body and Html body of a message use the SetMailMessageContent(String, String).

Note Note
If this method returns false the message will not be sent out to the subscriber.

Examples

The following example shows how to add an information message at the top of the text body of the message

C#
protected override bool ValidateMessage(SubscriptionInformation subscriber)
{
    //Start by performing the standard replacement operation
    //in the base class
    if(!base.ValidateMessage(subscriber))
        return false;
    //add your custom message to the body    
    string body = String.Concat("This message has been processed\r\n", OriginalBody);
    SetMailMessageContent(OriginalHtmlBody, body);
    return true;
}
See Also

Reference