Click here to Skip to main content
15,890,897 members
Articles / Programming Languages / C#

Email Client Application by Implementing Our Own SMTP and POP3 protocols using C#

Rate me:
Please Sign up or sign in to vote.
3.31/5 (32 votes)
9 Dec 2008GPL32 min read 210.9K   11.8K   106   81
In this email client application, I have implemented my own SMTP and POP3 protocols in C#.
Image 1

How to send an email message? (click on compose mail tab)

You can send an email message by using any SMTP server, which allows you to do so. For example, you can send an email message by using gmail smtp server (it is freely available) to any SMTP server like GMail, Yahoo, Hotmail, etc.

          gmail smtp server:   smtp.gmail.com 
          gmail smtp port:  587 
          user name:   gmail user id (without @gmail.com) 
          password:   gmail password

After providing the above information, you specify sender and recepient's email address. You can specify more than one recepient's email address; each is separated by comma or semi-colon. The fields cc and bcc are optional. Then you specify subject, add file attachments(if any), and write the actual message. You may apply formatting on the actual message. Then you click on send button in order to send the email. The status bar shows you progress information.

How to receive email messages? (click on check mail tab)

You can receive emails from any pop server, which allows you to do so. For example, gmail pop server is freely available. In order to use GMail pop service, you must first enable pop service by going into GMail settings. In GMail settings, click on "forwarding and pop/imap" option, then select "enable pop for all mail" option and after that click on save changes button. Now you can check your emails by using my email client application.

          gmail pop server:   pop.gmail.com 
          gmail pop port:   995 
          user name:   gmail user id with @gmail.com 
          password:   gmail password

After providing the above information, click on connect button. After connecting and verifying user name and password, all emails (if there exist any) will be displayed in the inbox. In order to delete an email, press right click on the email, a context menu will display, then select delete option. In order to display an email message, press left click on the email. After fetching the email from the pop server, it will be displayed to the user. If the email contains any file attachment, then the user can also save the file by first selecting it and then click on save option.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


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

Comments and Discussions

 
GeneralBody Format Problem Pin
AnnieRao29-Jul-09 4:19
AnnieRao29-Jul-09 4:19 
GeneralRe: Body Format Problem Pin
Rizwan Ahmed29-Jul-09 6:05
Rizwan Ahmed29-Jul-09 6:05 
QuestionRe: Body Format Problem Pin
AnnieRao26-Aug-09 20:49
AnnieRao26-Aug-09 20:49 
QuestionListView as ListBox for Compose Mail Attachment.. Pin
hamudiz3-Feb-09 2:59
hamudiz3-Feb-09 2:59 
Questionmessages in arabic problem Pin
startpoint25-Jan-09 3:13
startpoint25-Jan-09 3:13 
QuestionUnicode for arabic language Pin
startpoint25-Jan-09 3:08
startpoint25-Jan-09 3:08 
QuestionA doubt about attachments... txt files not recognised.... Pin
jlarini9-Jan-09 1:55
jlarini9-Jan-09 1:55 
AnswerRe: A doubt about attachments... txt files not recognised.... Pin
Rizwan Ahmed9-Jan-09 6:18
Rizwan Ahmed9-Jan-09 6:18 
Hi,

When you do left click on some message, then MailMessages_MouseClick() event handler is executed which is defined in EmailClient.cs file. In the event handler, the second condition is executed which internally creates a new thread to which I have associated a method named FetchEmailCallBack() defined in the same file. That method calls internally FetchEmail() method of Pop3Client class object. Now see FetchEmail() method which actually receives complete email. In the FetchEmail method, I am calling another method named is ParseEmail(). This ParseEmail() method is very important and difficult to understand (Not so Much!). In the ParseEmail() method, I am separating all sections of the received email. I am storing sections in mailSections arraylist. In this arraylist attached files are stored.

Now when you click on download file icon, DownloadAttachment_Click event handler is executed. This event handler calls internally GetMailSection() method of Pop3Client class. In that method, I just get file contents from mailSection arraylist on the basis of selected file index. This is all about getting attached files!

Rizwan Ahmed

AnswerRe: A doubt about attachments... txt files not recognised.... Pin
jlarini9-Jan-09 7:57
jlarini9-Jan-09 7:57 
GeneralRe: A doubt about attachments... txt files not recognised.... Pin
jlarini15-Jan-09 2:55
jlarini15-Jan-09 2:55 
GeneralRe: A doubt about attachments... txt files not recognised.... Pin
NitinMakwana31-Mar-10 19:16
NitinMakwana31-Mar-10 19:16 
GeneralRe: A doubt about attachments... txt files not recognised.... Pin
NitinMakwana31-Mar-10 21:43
NitinMakwana31-Mar-10 21:43 
QuestionCross-thread error... Pin
jlarini8-Jan-09 7:50
jlarini8-Jan-09 7:50 
AnswerRe: Cross-thread error... Pin
Rizwan Ahmed8-Jan-09 11:31
Rizwan Ahmed8-Jan-09 11:31 
GeneralRe: Cross-thread error... Pin
jlarini9-Jan-09 1:08
jlarini9-Jan-09 1:08 
QuestionException of type 'Email_Client.Pop3ClientException' was thrown. Pin
Tapas Ranjan Singh8-Jan-09 2:12
Tapas Ranjan Singh8-Jan-09 2:12 
AnswerRe: Exception of type 'Email_Client.Pop3ClientException' was thrown. Pin
Rizwan Ahmed8-Jan-09 5:38
Rizwan Ahmed8-Jan-09 5:38 
GeneralRe: Exception of type 'Email_Client.Pop3ClientException' was thrown. Pin
Tapas Ranjan Singh8-Jan-09 18:53
Tapas Ranjan Singh8-Jan-09 18:53 
GeneralRe: Exception of type 'Email_Client.Pop3ClientException' was thrown. Pin
Rizwan Ahmed8-Jan-09 21:15
Rizwan Ahmed8-Jan-09 21:15 
GeneralRe: Exception of type 'Email_Client.Pop3ClientException' was thrown. Pin
Nurulhuda19-Apr-09 22:23
Nurulhuda19-Apr-09 22:23 
QuestionRe: Exception of type 'Email_Client.Pop3ClientException' was thrown. Pin
NitinMakwana3-Mar-10 18:56
NitinMakwana3-Mar-10 18:56 
AnswerRe: Exception of type 'Email_Client.Pop3ClientException' was thrown. Pin
Member 129251475-Apr-17 6:16
Member 129251475-Apr-17 6:16 
GeneralNot Receive Emails sent by your application Pin
Member 15187116-Dec-08 1:52
Member 15187116-Dec-08 1:52 
GeneralRe: Not Receive Emails sent by your application Pin
Rizwan Ahmed16-Dec-08 4:55
Rizwan Ahmed16-Dec-08 4:55 
GeneralRe: Not Receive Emails sent by your application Pin
Member 15187116-Dec-08 14:43
Member 15187116-Dec-08 14:43 

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.