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

POP3 Library in C#

Rate me:
Please Sign up or sign in to vote.
1.86/5 (20 votes)
26 Sep 2003 187.4K   4.4K   40   42
Complete POP3 Library with Attachment read and Save option

Introduction

POP3 Library is an implementation of POP3 protocol. This library supports attachments within the messages and uses delegates in C# to provide with all the necessary feedback to the user of the library.

POP3 events from the library are passed to the client application by means of delegates:

C#
public delegate void POP3Error(string errorMsg);
public delegate void 
     POP3MsgRetrivalStatus(int MsgNumber,int MsgSize,int MsgRetsize);
public delegate void POP3Complete();
public delegate void POP3MsgComplete(int MsgNumber,string MsgHeader);

The simple interface provided by the library can be used by any GUI application to get the POP3 messages.

public POP3(string UserName,string Password,string Server,bool DelAfterRead) is the constructor, which accepts the username, password, server, and property to delete the message after read.

A sample application to use the library is provided with this article.

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
South Africa South Africa
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questiongetting attachments from email Pin
RudyB2-Jan-12 1:32
RudyB2-Jan-12 1:32 
GeneralRecieveCallback errorThe I/O operation has been aborted because of either a thread exit or an application request Pin
ishika_d3110-Apr-09 13:03
ishika_d3110-Apr-09 13:03 
GeneralThanks! Pin
Adam Crawford17-Oct-07 4:57
Adam Crawford17-Oct-07 4:57 
GeneralWrong reference to an object Pin
AlbinWorld4-Jan-06 23:28
AlbinWorld4-Jan-06 23:28 
GeneralRe: Wrong reference to an object Pin
AlbinWorld5-Jan-06 0:11
AlbinWorld5-Jan-06 0:11 
Generalit Doesnt work Pin
nazli7-Mar-05 1:00
nazli7-Mar-05 1:00 
GeneralBOKA CHODA .SUAR KA BACHHA,LAVRA. KHANKI, DHAMNA Pin
tappi3-Nov-04 17:51
tappi3-Nov-04 17:51 
GeneralDon't funca Pin
japasofts12-Jun-04 15:00
japasofts12-Jun-04 15:00 
GeneralCPOP3.cs Line 204 bug... Pin
Sung-Ho, Hong9-Jun-04 17:01
Sung-Ho, Hong9-Jun-04 17:01 
GeneralRe: CPOP3.cs Line 204 bug... Pin
Adam Crawford17-Oct-07 4:52
Adam Crawford17-Oct-07 4:52 
Questioncan i use this using vb.net? Pin
gleceper8-Jun-04 16:21
gleceper8-Jun-04 16:21 
GeneralPOP3 Attachment, Please help me Pin
tungbui14-May-04 16:49
tungbui14-May-04 16:49 
GeneralMessage Closed Pin
6-Nov-05 12:54
lesnikowski6-Nov-05 12:54 
GeneralPOP3 Bug Pin
tungbui11-May-04 17:48
tungbui11-May-04 17:48 
GeneralDelete after read Pin
jimaya7-Mar-04 2:03
jimaya7-Mar-04 2:03 
GeneralAttachment Pin
Member 77858123-Feb-04 1:09
Member 77858123-Feb-04 1:09 
QuestionPOP3 with SSL??? Pin
xhris10-Feb-04 18:18
xhris10-Feb-04 18:18 
AnswerRe: POP3 with SSL??? Pin
Anonymous22-Feb-05 14:06
Anonymous22-Feb-05 14:06 
GeneralAttachment Pin
Thomas Phan30-Nov-03 16:07
Thomas Phan30-Nov-03 16:07 
GeneralRe: Attachment Pin
Jeffrey Scott Flesher31-Dec-03 7:04
Jeffrey Scott Flesher31-Dec-03 7:04 
Overall this code is a great starting point as someone pointed out. I have the SoftArtisans POP3 Beta 2 dated 12 June 2002 w/source; this was designed as an Asp.Net component, I was planning on using it on my web site but haven’t as of yet. The code is no longer supported and SoftArtisans has said that this should become a community project. I don’t know about its suitability for Windows Apps; which is why I’m looking for better code like this project that can be fixed if we all work together. I’d be glad to share my fixes as I make them; I’m working on the Attachments now.
A few things I found odd:
//check if this is attachment or not
private bool IsAttachment(string src)
{
int where = src.IndexOf("Content-Disposition:");
changed it to
int where = src.IndexOf("Content-Type: multipart/alternative;");
. . .
I know this isn’t right but it works for this one attachment; I have a feeling that I don’t know enough about the POP3 protocol and I’m going to have to learn it even though this isn’t what I want to do, I’m off on the beaten path of the work I stated.
private void ParseMessage()
. . .
case STATE.RETR:
. . .
if(tmp.msgSize == (tmp.retrSize - 3))
changed it to
if(tmp.msgSize < (tmp.retrSize - 3))
As mentioned by someone else the problem appears to be the size reported but the fix gets me passed this issue but the problem remains.
Email me if you want.


Lessons learned from 911:

1. United We Stand.

2. United’s We Fall.

Gulf War Syndrome survivors never have a good day. http://www.vetshelpcenter.com/
GeneralRe: Attachment Pin
loop0716-Sep-04 16:34
loop0716-Sep-04 16:34 
GeneralRe: Attachment Pin
Jeffrey Scott Flesher5-Jul-05 9:07
Jeffrey Scott Flesher5-Jul-05 9:07 
GeneralPlease Pin
surya sekhar bhattacharya3-Nov-04 18:04
surya sekhar bhattacharya3-Nov-04 18:04 
GeneralRe: Please Pin
Jeffrey Scott Flesher5-Jul-05 9:09
Jeffrey Scott Flesher5-Jul-05 9:09 
GeneralRe: Attachment Pin
tomstrummer5-Jul-05 4:05
tomstrummer5-Jul-05 4:05 

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.