Click here to Skip to main content
Licence CPOL
First Posted 6 Jun 2006
Views 23,965
Bookmarked 18 times

Simple Email Formatter Framework - Using C#, Smtp

By | 6 Jun 2006 | Article
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. 

 IEmailFormatter    

Concrete class MQExceptionFormatter

Class MQExceptionEmailFormatter, A concrete class which implements this interface. This class helps formatting email message for a MSMQ message. 

 

  MQExceptionEmailFormatter.jpg

Similarly different formatter classes can be implemented according to the need by implementing the interface.

Implement FormatMessage() function to format an email

following piece of code shows a sample implementation of the FormatMessage() function by the MQExceptionEmailFormatter class.

 Implement_FormatMessage_function.jpg

  If the email format is standardized then we could implement an abstract Email Formatter class having a default implementation for the FormatMessage() function and have all the other  concrete formatter classes extend this abstract class.

 Class EmailPublisher using IEmailFormatter types

 Class EmailPublisher now uses IEmailFormatter type in it's implementation and hence can use any of the IEmailFormatter concrete classes to access email subject and Email body.

 PublishEmail.jpg

 SendMail...

The SendMail Function internally accesses formatting information from the formatter classes.

PublishEmail

Sample Usage

 Usage1.jpg

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Aravind Rajagopal K

Software Developer (Senior)
UMASS Medical School
United States United States

Member

A Certified .NET MCSD (Microsoft Certified Solution Developer)that specializes in Microsoft technologies architecting/designing/developing applications using .NET (C# or VB), ASP.NET, SQL Server and BizTalk.
I have contributed as a designer/developer for benchmarked products in the finance industry benchmarked for best transaction engine design and products that offer end to end solution to research based content. Currently working with UMASS Medical School at Worcester MA.
 
Hobbies include music,reading books and playing cricket.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalgood one. few suggestions:- PinmemberJaikanth15:56 8 Jun '06  
GeneralRe: good one. few suggestions:- PinmemberAravind K Rajagopal4:23 27 Jun '06  
QuestionScreenshots ??? Pinmemberburning snow11:09 6 Jun '06  
AnswerRe: Screenshots ??? PinmemberAravind K Rajagopal4:19 27 Jun '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 6 Jun 2006
Article Copyright 2006 by Aravind Rajagopal K
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid