Click here to Skip to main content
11,926,429 members (51,975 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


41 bookmarked

IMAP and POP3 Clients in C#

, 28 Sep 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
IMAP & POP3 Clients C#. A library for intuitive ease of use of these two protocols.


Searching on the web I was never able to find a library simple and effective way to manage email client with IMAP or POP3 without having to create a good wrapper.

So I decided to make available to the wrapper that is currently used to handle these two protocols. 


This library is a library wrapper of free Limisoft library (attached in the download). Lumisoft web site

This library allows you to create a client or IMAP or POP3 is 100% compatible with servers such as:

  • Gmail
  • Windows Live

Servers Libero, AOL, Exchange, Yahoo, etc.. are still in testing and not sure the 100% working. The POP3 protocol is implemented based on RFC 1939 Link .

The IMAP protocol is implemented based on the standard Internet Message Access Protocol - Version 4 rev1 Link .

Using the code

This simple library to be able to create basic client using the two protocols used in the web: IMAP and POP3

The library exposes two interfaces: IMailClient and IMail.

public interface IEmail 

public interface IEmailClient 

IEmail is an instance of an email message on server. IEmailClient is an instance of a POP3 or IMAP client.

To construct an instance of a client to be used the factory "EmailClientFactory" passing the method "GetClient" the type of protocol you want to use

public static class EmailClientFactory
    public static IEmailClient GetClient(EmailClientEnum type)
        if (type == EmailClientEnum.IMAP) return new IMAP_Wrapper();
        if (type == EmailClientEnum.POP3) return new POP3_Wrapper();
        return null;

The interface IMailClient allows to manage the clients in the same way.

public interface IEmailClient
    event EmailClient_OnMessagesLoaded OnMessagesLoaded;
    bool IsConnected
    List<IEmail> Messages
    void Connect(String server, String User, String pass, int port, bool useSSl);
    void Disconnect();
    void SetCurrentFolder(String folder);
    int GetMessagesCount();
    void LoadMessages();
    void LoadMessages(String start, String end);
    void LoadRecentMessages(Int32 lastSequenceNumber);

Using the library

IEmailClient ImapClient = EmailClientFactory.GetClient(EmailClientEnum.IMAP); 
ImapClient.Connect("", "", "examplePass", 993, true);    
// I assume that 5 is the last "ID" readed by my client. 
// If I want to read all messages i use "ImapClient.LoadMessages();"
// To read all my messages loaded:
for (int i = 0; i < ImapClient.Messages.Count; i++)
    IEmail msm = (IEmail)ImapClient.Messages[i];
    // Load all infos include attachments
    Console.Writeline(msm.Date.ToString() + " - " + msm.From[0] + " - " + 
                      msm.Subject + " - " + msm.Attachments.Count);


27/09/2012 : First version


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


About the Author

D.Net Solutions
Software Developer (Senior) D.Net Solution
Italy Italy
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralRe: not read emails Pin
Wilhelm Meier18-Dec-12 6:38
memberWilhelm Meier18-Dec-12 6:38 
GeneralRe: not read emails Pin
Wilhelm Meier18-Dec-12 6:41
memberWilhelm Meier18-Dec-12 6:41 
GeneralRe: not read emails Pin
D.Net Solutions18-Dec-12 22:17
memberD.Net Solutions18-Dec-12 22:17 
GeneralRe: not read emails Pin
Wilhelm Meier19-Dec-12 3:21
memberWilhelm Meier19-Dec-12 3:21 
Questioncan you provide some guide line Pin
Susheelbn15-Dec-12 1:17
memberSusheelbn15-Dec-12 1:17 
AnswerRe: can you provide some guide line Pin
D.Net Solutions17-Dec-12 3:14
memberD.Net Solutions17-Dec-12 3:14 
GeneralRe: can you provide some guide line Pin
Member 1180220030-Jun-15 23:01
memberMember 1180220030-Jun-15 23:01 
QuestionDelete email Pin
Bitteron13-Dec-12 22:31
memberBitteron13-Dec-12 22:31 
How to mark fo deletion (or simply delete) message(s)? Your class already got it or i must do it for my self?
AnswerRe: Delete email Pin
D.Net Solutions14-Dec-12 0:40
memberD.Net Solutions14-Dec-12 0:40 
QuestionRe: Delete email Pin
levelboy11-Jul-13 2:56
memberlevelboy11-Jul-13 2:56 
AnswerRe: Delete email Pin
Member 1103443315-Oct-14 1:26
memberMember 1103443315-Oct-14 1:26 
QuestionI am a newbie here and need help with this Pin
GPS Waraich13-Dec-12 3:50
memberGPS Waraich13-Dec-12 3:50 
AnswerRe: I am a newbie here and need help with this Pin
D.Net Solutions14-Dec-12 0:42
memberD.Net Solutions14-Dec-12 0:42 
GeneralMy vote of 4 Pin
mansoor.siddique14-Nov-12 5:49
membermansoor.siddique14-Nov-12 5:49 
GeneralAttachments Pin
antonio_l4-Oct-12 4:07
memberantonio_l4-Oct-12 4:07 
GeneralRe: Attachments Pin
D.Net Solutions4-Oct-12 22:19
memberD.Net Solutions4-Oct-12 22:19 
GeneralRe: Attachments Pin
antonio_l5-Oct-12 1:38
memberantonio_l5-Oct-12 1:38 
GeneralRe: Attachments Pin
antani7430-Jul-15 4:28
memberantani7430-Jul-15 4:28 
QuestionProblem using this library Pin
Member 392317128-Sep-12 3:58
memberMember 392317128-Sep-12 3:58 
AnswerRe: Problem using this library Pin
D.Net Solution28-Sep-12 4:04
memberD.Net Solution28-Sep-12 4:04 
GeneralRe: Problem using this library Pin
Member 392317128-Sep-12 4:17
memberMember 392317128-Sep-12 4:17 
GeneralRe: Problem using this library Pin
D.Net Solution28-Sep-12 4:20
memberD.Net Solution28-Sep-12 4:20 
GeneralRe: Problem using this library Pin
Member 775724528-Sep-12 9:43
memberMember 775724528-Sep-12 9:43 
GeneralRe: Problem using this library Pin
D.Net Solutions2-Oct-12 1:38
memberD.Net Solutions2-Oct-12 1:38 
GeneralRe: Problem using this library Pin
Member 77572452-Oct-12 10:20
memberMember 77572452-Oct-12 10:20 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151126.1 | Last Updated 28 Sep 2012
Article Copyright 2012 by D.Net Solutions
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid