Click here to Skip to main content
Click here to Skip to main content

Using POP3 with C# to download and parse your mail.

, 17 Nov 2002 CPOL
Rate this:
Please Sign up or sign in to vote.
Using this class in your C# application you can manage your mailbox and download and parse your messages.


This article explains a simple way to add mail support in your application. Just use the classes:

POP3class methods:

  • string DoConnect(String pop3host,int port, String user, String pwd)
  • string GetStat()
  • string GetList()
  • string GetList(int num)
  • string Retr(int num)
  • string Dele(int num)
  • string Rset()
  • string Quit()
  • string GetTop(int num)
  • string GetTop(int num_mess, int num_lines)
  • string GetUidl()
  • string GetUidl(int num)
  • string GetNoop()

MessageClass methods:

  • string GetFrom(string messTop)
  • string GetDate(string messTop)
  • string GetMessID(string messTop)
  • string GetTo(string messTop)
  • string GetSubject(string messTop)
  • string GetBody(string AllMessage)

Using the code

The following sample illustrates how to use the classes:

POP3class pop3;
pop3 = new POP3class();
// and if we have mail:
MessageClass msg;
msg = new MessageClass();
string sMessageTop = msg.GetTop(1);
//OK, message is well, lets download it.
string sAllMessage = msg.Retr(1);

That's all.


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


About the Author

Karavaev Denis
Systems Engineer
Russian Federation Russian Federation
Now in Moscow.

Comments and Discussions

QuestionGood News !! Visual Studio now has support for POP3, SMTP, IMAP, etc PinmemberTino Fourie21-Feb-14 10:59 
Questionmsg.GetTop() Pinmemberbrob199013-Nov-13 15:15 
GeneralMy vote of 5 PinprofessionalAmir Mohammad Nasrollahi29-Jul-13 22:49 
GeneralMy vote of 5 Pinmemberreldridge10-Feb-12 11:49 
GeneralGreat Job PinmemberLokesh_193744414-Sep-10 18:46 
GeneralCan't run with Gmail Pinmemberanki1236-Jul-09 23:51 
GeneralRe: Can't run with Gmail Pinmember1234anand1-Sep-09 0:13 
GeneralGmail Account PinmemberAriel Piñeiro26-Jun-09 8:14 
Generalnice class... Pinmemberlamarez28-Dec-08 13:10 
Generalits saying -ERR System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it. plz help PinmemberMember 27193538-Dec-08 10:07 
GeneralGetTop is not a function in Mesaage Class. Pinmemberanjani_jan194-Jul-08 1:46 
GeneralRe: GetTop is not a function in Mesaage Class. PinmemberJackieHoffman18-Nov-08 15:09 
Generalhelp !!!!!!!!!!!!!!!! PinmemberHorra1-Mar-08 9:31 
GeneralIam getting this error Input string was not in a correct format And login is ok but iam not getting the mails ..plz help me Pinmemberanjaneya75-Feb-08 1:57 
GeneralHelp me!!! Pinmembersaobangtn2231-Aug-07 18:15 
GeneralRe: Help me!!! Pinmemberhe2he29-Oct-07 5:23 
GeneralSTD3 violation Pinmembermastdk21-Sep-06 4:36 
GeneralNice one PinmemberGav_Roberts2k511-Oct-05 22:56 
GeneralSSL Support PinmemberNihal Chand10-Oct-05 20:06 
GeneralRe: SSL Support Pinmembernovice__geek14-Mar-09 20:04 
GeneralError in GetMail (MailPOP3.cs) PinmemberMemot7-Jul-04 5:40 
QuestionThere is the function GetBody? PinmemberAlbert Pascual6-Aug-03 6:06 
Generali can't it Pinmemberoeurun6-Aug-03 3:11 
GeneralI can not seem to get the email headers, etc PinmemberJediman6-Jul-03 15:24 
GeneralRe: I can not seem to get the email headers, etc PinmemberJackieHoffman18-Nov-08 15:14 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150123.1 | Last Updated 18 Nov 2002
Article Copyright 2002 by Karavaev Denis
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid