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

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

Sends the message to the specified subscriber.

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

protected override bool SendMessage(
	SubscriptionInformation subscriber
)

Parameters

subscriber
Type: ContentStudio.Document.Subscription.EventHandlerSubscriptionInformation
The subscriber to send the message to.

Return Value

Type: Boolean
true if the message was sent; otherwise, false
Exceptions

ExceptionCondition
InvalidOperationException'Message' or 'SmtpClient' are not intialized
SmtpException
Remarks

The implementation in this class implements a basic Smtp server sending routine. Deriving classes can override this method to implement its own sending routine or custom logging routines.

This implementation only logs errors, to implement success logging and logging of omitted receivers, override this method.

Examples

This small sample shows how to add logging to a custom event handler when a message has been sent or when a message was not sent for some reason.

C#
protected override bool SendMessage(SubscriptionInformation subscriber)
{
    //Send the message by calling the base class implementation
    if (base.SendMessage(subscriber))
    {
        //A message has been sent successfully, log this as an informational message 
        WriteToLog(SyslogPriority.Informational, String.Format("Mail sent to {0}.", subscriber));
        return true;
    }
    //The message was not sent to this person, log a warning message
    WriteToLog(SyslogPriority.Warning, String.Format("Mail could not be sent to {0}.", subscriber));
    return false;
}
See Also

Reference