Click or drag to resize

Router Class

A class representing a Message Router.
Inheritance Hierarchy
SystemObject
  SMTPRouterRouter

Namespace:  SMTPRouter
Assembly:  SMTPRouter (in SMTPRouter.dll) Version: 1.0.0.4
Syntax
public sealed class Router

The Router type exposes the following members.

Constructors
  NameDescription
Public methodRouter
Initializes a new instance of a Router
Public methodRouter(String)
Initializes a new instance of a Router and sets the Queue Path to be the Current Directory
Public methodRouter(String, String)
Initializes a new instance of a Router
Top
Properties
  NameDescription
Public propertyDestinationSmtps
A Dictionary containing the Smtp Configuration based on a Key name
Public propertyFolders
A structure representing the queue folders
Public propertyIsInitialized
Returns a flag to inform if the router is initialized
Public propertyIsPaused
Defines whether the routing process is Paused or Running
Public propertyMessageLifespan
The TimeSpan a message is stil considered valid to retry. By default, a message lasts 15 minutes after its creation time
Public propertyMessagePurgeLifespan
The TimeSpan a message remains on the queues. By default a message remains there for 90 days before being purged.
Public propertyQueueName
Represents the Queue Name
Public propertyQueuePath
Represents the Queue Path
Public propertyRoutingRules
List of Rules to be applied when routing messages
Top
Methods
  NameDescription
Public methodEnqueue
Adds a message to the proper queue
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLoadRoutingRules
Load Routing Rules from a Text File
Public methodLoadSmtpConfiguration
Load Smtp Configuration from a Text File
Public methodPurgeQueues
Purges queues for messages older then the MessagePurgeLifespan
Public methodSaveRoutingRules
Saves the existing routing rules to a text file
Public methodSaveSmtpConfiguration
Saves the existing Smtp Configuration to a Text File
Public methodStartAsync
Starts the Message Routing
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Events
  NameDescription
Public eventGeneralError
Event triggered when a general error happens on the processing
Public eventMessageNotRouted
Event triggered when a message could not be routed successfully
Public eventMessagePurging
Event triggered when a message is about to be purged by the system.
Public eventMessageRoutedSuccessfully
Event triggered when a message is routed successfully
Public eventMessagesPurged
Event triggered after messages are purged
Top
Remarks
The router receives the message and then routes it
Examples
A Router can be created using the code below:
// Create the Router
var router = new SMTPRouter.Router("SMTPRouter", "C:\\SMTPRouter\\Queues")
{
    MessageLifespan = new TimeSpan(0, 15, 0),
    RoutingRules = new List<Models.RoutingRule>()
    {
        new Models.MailFromDomainRoutingRule(10, "gmail.com", "gmail"),
        new Models.MailFromDomainRoutingRule(20, "hotmail.com", "hotmail")
    },
    DestinationSmtps = new Dictionary<string, Models.SmtpConfiguration>
    {
        { "gmail", new Models.SmtpConfiguration()
            {
                Host = "smtp.gmail.com",
                Description = "Google Mail SMTP",
                Port = 587,
                RequiresAuthentication = true,
                User = "user@gmail.com",
                Password = "",
            }
        },
        { "hotmail", new Models.SmtpConfiguration()
            {
                Host = "smtp.live.com",
                Description = "Hotmail SMTP",
                Port = 587,
                RequiresAuthentication = true,
                User = "user@hotmail.com",
                Password = "",
            }
        }
    },
};
router.MessageRoutedSuccessfully += Server_MessageRoutedSuccessfully;
router.MessageNotRouted += Server_MessageNotRouted;
See Also