Simple Email Formatter Framework - Using C#, Smtp






2.33/5 (5 votes)
This article explains a simple Email formatter framework in conjunction with an EmailPublisher class to format and send email messages.
Introduction
This article explains a simple Email formatter framework. This would enable programmers to extend/implement custom email formatter classes. This in conjunction with an Email Publisher class can be very useful for web applications,smart client applications and windows services to format and send emails. We have several articles and code snippetts for publishing emails but none for formatting emails. This sample, abstracts out email formatting part and later integrates it into an Email Publisher class.
IEmailFormatter interface
IEmailFormatter interface defines the contract for the framework. All formatter classes have to implement this contract.
Concrete class MQExceptionFormatter
Class MQExceptionEmailFormatter, A concrete class which implements this interface. This class helps formatting email message for a MSMQ message.

Implement FormatMessage() function to format an email
Class EmailPublisher using IEmailFormatter types
SendMail...
The SendMail Function internally accesses formatting information from the formatter classes.
Sample Usage