Click here to Skip to main content
15,888,733 members
Articles / Programming Languages / C#
Article

Email Component for .NET

Rate me:
Please Sign up or sign in to vote.
2.34/5 (30 votes)
27 Oct 20033 min read 203.2K   3.8K   56   48
cpSphere.Mail is a comprehensive and extendable implementation of MIME, POP and SMTP RFCs. This is architected to provide a framework for all email related development. This component could be used with default options with less or no knowledge of underlying MIME, POP, SMTP protocols.

The latest version can be found at GotDotNet

Introduction

cpSphere.Mail is a comprehensive and extendable implementation of MIME, POP and SMTP RFCs. This is architected to provide a framework for all email related development. Like all Microsoft .NET class libraries, this component could be used with default options with less or no knowledge of underlying MIME, POP, SMTP protocols. Alternatively, one can gain full control over all email communications including MIME headers, server communications etc.

Features

cpSphere.Mail component supports a number of features that stands it out amongst other implementations. These features include:

  • Fully Managed code - Written 100% in C# for CLR.
  • Absolutely Free - The component is free to use, you only need to register it and get License Key.
  • Visual Studio Integration - cpSphere.Mail is fully integrated with Visual Studio .NET.
  • Scalable Architecture - cpSphere.Mail library is designed with future extension in mind. You can use it out-of-box or extend it for granular control.

cpSphere.Mail.Mime Features

The classes in cpSphere.Mail.Mime namespace make it easy to work with even the most complex MIME email messages. Some of the many supported features include:

  • A complete implementation of the latest MIME specifications.
  • Full control on Mime message headers.
  • Support for custom header parsing.
  • Support for Unicode character set in message headers and body.
  • Unlimited attachments.
  • Attachment decoding and encoding - comes with support for Base64, Quoted-Printable and Uuencode, and support for custom encoding.
  • Collection of all body parts - all the parts of a mime message are accessible using MessagePartCollection.
  • Collection of recipient emails - All the recipients and senders email addresses are accessible using EmailAddressCollection.
  • Native support for message Reply and Forwarding.
  • Support for serialization for individual message part or complete message.

cpSphere.Mail.Pop Features

The classes in cpSphere.Mail.Pop namespace implement POP3 Protocol as defined in related RFCs. These classes let you connect to a POP3 server and retrieve email messages using standard methods. Out-of-box functionality lets you retrieve individual message/message header or n number of messages. Few of the striking features are:

  • Total access and control over POP3 server.
  • Support for all the standard POP3 commands and mechanism to use extended capabilities of a POP3 server.
  • Full control on downloaded messages.
  • Built-in cache for downloaded messages.
  • Ability to download only headers for messages.
  • Ability to set operation wait time.
  • Asynchronous Programming model.
  • Message download progress events.

cpSphere.Mail.Smtp Features

Classes in cpSphere.Mail.Smtp namespace not only provide easy methods to send messages using ESMTP protocol, they also provide full control over the message sending operations. Out-of-the-box, these classes detect the extended capabilities supported by the SMTP server and send messages by employing the most optimized method to send message. For example, if a server supports Pipelining and Chuncking of data, SendXXX methods will use Pipelining, hence saving number of return calls. Some interesting supported features are:

  • Progress Monitoring events.
  • Delivery Status Notification Support.
  • Support for cancellation of sending operation.
  • High performance throughput - component automatically checks for extended server capabilities and uses most optimized method to send email messages.
  • Unlimited recipients.
  • Full control on SMTP server.

How this code is organized:

For complete discussion on how this code is organized, please download the help file from here. I have also included a very detailed demo project to jump start the development.

I hope this component will be helpful in your development. I have created a GDN workspace here for its development, and will appreciate if you use that to coordinate further development of this code.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralUnhandle Timeout Error Pin
nyeinchan.ucsm3-May-11 17:23
nyeinchan.ucsm3-May-11 17:23 
QuestionUnmanaged Code Pin
Yisman228-Dec-09 21:09
Yisman228-Dec-09 21:09 
GeneralBody Part Pin
aniket_code20-Dec-08 2:00
aniket_code20-Dec-08 2:00 
QuestionHow to get Bounced mail from POP3 Pin
Deepesh Jain...1-Dec-08 23:40
Deepesh Jain...1-Dec-08 23:40 
Generalbounce email address Pin
Member 365198730-Oct-08 1:22
Member 365198730-Oct-08 1:22 
GeneralNo such host is known Pin
Member 33979239-Mar-08 18:07
Member 33979239-Mar-08 18:07 
GeneralFixing the download issue Pin
fixie_pczone28-Aug-07 21:39
fixie_pczone28-Aug-07 21:39 
GeneralProblem: valid license could not be granted Pin
castilloJeffersonS11-Apr-07 23:46
castilloJeffersonS11-Apr-07 23:46 
GeneralI found bug Pin
homer JS19-Jul-06 23:30
homer JS19-Jul-06 23:30 
QuestionSerialization Pin
homer JS19-Jul-06 22:49
homer JS19-Jul-06 22:49 
AnswerRe: Serialization Pin
homer JS19-Jul-06 23:20
homer JS19-Jul-06 23:20 
GeneraliCalendar Pin
tlijun20-Apr-06 11:33
tlijun20-Apr-06 11:33 
GeneralThis is a real mess Pin
Ben Peterson26-Apr-05 5:36
Ben Peterson26-Apr-05 5:36 
1 -- It was necessary to remove various odd license things from the source before attempting to use it. Is the code being released to benefit the user, or to make the author feel important?

2 -- It is unstable. For example, connecting twice is a certain uncaught exception for the following two reasons: _isConnected does not get set to false when a connection is closed, and the socket (hidden in it's layers of wrapper classes) gets disposed when the connection is closed, and then never re-initialized. Presumably connecting more than once was never tested.

3 -- It is extremely unstable! Look at the messagesCache field. When is anything removed from it? That's right -- it grows indefinitely. Better still, in Pop3.Login, if messagesCache.Count is bigger than msgSize.Count, the login fails because you compare the index into msgSize with the length of messagesCache! This is a deal-breaking bug (one of many) and it's there because you were busy feeling clever and didn't keep track of what your various collections mean.

4 -- It does weird things. For instance, GetMessages() throws an exception when there are 0 messages on the server. Returning a list of messages of length 0 would have been much better. Actually, there is a general sense of 'zero length collections are an error' throughout the code, and a general use of exceptions to indicate things that are not errors.

5 -- It does not actually implement POP3 correctly or completely. For instance, look at the assumption the DeleteAll method makes about message numbers. A correctly-behaving POP server will return 'Protocol Error' when faced with that.

6 -- It is vastly overengineered. A good example of this is the pseudo-state machine structure. POP3 is a request/response protocol with very little state -- the fact that your 'state machine' has only three states and one of them does not actually do anything should suggest to you that something is wrong!

7 -- It is really vastly overengineered! Pretty much every class cries out to be held up as an example here. A simple socket connect is a 38-line function in a special custom TcpSocket class from which PopTcpSocket is then inherited.

8 -- Minor points: There are bitmaps included with the POP and SMTP classes. Better to keep some separation going between interface and logic. The code layout is a bit odd -- ending a line with 'new' is a new one for me.


I'm sorry to be crabby, but there are very severe issues with this library and they are issues that would not be there if the author had spent less time thinking of himself as a software architect and more time actually implementing the protocol in question. To fix the code, I would try to:

1 -- Reduce it to about 2/3 the current length, in total.
2 -- Get rid of the socket wrappers, 'state machine', etc.
3 -- Get rid of, or comment, the black magic -- e.g. that strange byte array full of odd numbers in the Recieve() method.
4 -- WRITE UNIT TESTS!! And use them! This is very important.
5 -- Make it nice to use -- for instance, make message parts available as strings or byte[]s as well as streams.

Once again, I'm sorry to be arrogant, critical, supercilious, and bad-tempered -- but for various reasons I have had to spend a great deal of time making this code work, and it has not been a simple or pleasant task!

You'd also better fix the various places where it says Kamran M. Qamar, the guru behind this compoenet. Unfortunately, those words are very revealing. Unsure | :~



URL: http://www.jbrowse.com
Favorite Toy: http://www.ruby-lang.org
GeneralUmmm...ya Pin
22-Jul-05 12:02
suss22-Jul-05 12:02 
GeneralMessage Closed Pin
12-May-12 23:26
lesnikowski12-May-12 23:26 
GeneralWARNING!! Source code Compiled in \bin\debug\cpSphereCertificate.dll Pin
esman24-Apr-05 0:23
esman24-Apr-05 0:23 
GeneralRe: WARNING!! Source code Compiled in \bin\debug\cpSphereCertificate.dll Pin
russ_h11-Jul-05 19:18
russ_h11-Jul-05 19:18 
GeneralProblem with attachments. downloaded file with size = 0 Pin
Alexander Wolff23-Feb-05 9:26
Alexander Wolff23-Feb-05 9:26 
GeneralRe: Problem with attachments. downloaded file with size = 0 Pin
gimarro9-Feb-07 4:21
gimarro9-Feb-07 4:21 
GeneralMessage Closed Pin
12-May-12 23:25
lesnikowski12-May-12 23:25 
GeneralExtremely useful code!!! Pin
fbuscaroli20-Feb-05 2:47
fbuscaroli20-Feb-05 2:47 
GeneralI think you'd better open your source code. Pin
Ivan Lee (CN)27-Nov-04 4:12
Ivan Lee (CN)27-Nov-04 4:12 
General"Complete source code" - not really Pin
Bill Seddon24-Jul-04 11:22
Bill Seddon24-Jul-04 11:22 
QuestionWhere is the source code? Pin
mrabie23-Jun-04 15:57
mrabie23-Jun-04 15:57 
GeneralHandling Mime in C# Pin
Rehman Adil29-Apr-04 21:51
Rehman Adil29-Apr-04 21:51 

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

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