Click here to Skip to main content
Licence CPOL
First Posted 7 Nov 2002
Views 145,208
Downloads 5,494
Bookmarked 69 times

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

By Karavaev Denis | 17 Nov 2002
Using this class in your C# application you can manage your mailbox and download and parse your messages.
4 votes, 20.0%
1
3 votes, 15.0%
2
1 vote, 5.0%
3
5 votes, 25.0%
4
7 votes, 35.0%
5
3.25/5 - 23 votes
μ 3.24, σa 2.80 [?]

Introduction

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();
pop3.DoConnect("your.mail.server",110,"username","password");
pop3.GetStat();
// 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);
msg.GetBody(sAllMessage);

That's all.

License

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

Member
Now in Moscow.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 Pinmemberreldridge11:49 10 Feb '12  
GeneralGreat Job PinmemberLokesh_193744418:46 14 Sep '10  
GeneralCan't run with Gmail Pinmemberanki12323:51 6 Jul '09  
Hi all,
 
I m able to run this library with yahoo account but it
can not work with Gmail account.
 
for pop3 server I m using -- pop.gmail.com
& Port - 995 or 110
 
but it can't work.
 
Plz help me
 
Thanks in advance
GeneralRe: Can't run with Gmail Pinmember1234anand0:13 1 Sep '09  
GeneralGmail Account PinmemberAriel Piñeiro8:14 26 Jun '09  
Generalnice class... Pinmemberlamarez13:10 28 Dec '08  
Generalits saying -ERR System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it. plz help PinmemberMember 271935310:07 8 Dec '08  
GeneralGetTop is not a function in Mesaage Class. Pinmemberanjani_jan191:46 4 Jul '08  
GeneralRe: GetTop is not a function in Mesaage Class. PinmemberJackieHoffman15:09 18 Nov '08  
Generalhelp !!!!!!!!!!!!!!!! PinmemberHorra9:31 1 Mar '08  
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 Pinmemberanjaneya71:57 5 Feb '08  
GeneralHelp me!!! Pinmembersaobangtn2218:15 31 Aug '07  
GeneralRe: Help me!!! Pinmemberhe2he5:23 29 Oct '07  
GeneralSTD3 violation Pinmembermastdk4:36 21 Sep '06  
GeneralNice one PinmemberGav_Roberts2k522:56 11 Oct '05  
GeneralSSL Support PinmemberNihal Chand20:06 10 Oct '05  
GeneralRe: SSL Support Pinmembernovice__geek20:04 14 Mar '09  
GeneralError in GetMail (MailPOP3.cs) PinmemberMemot5:40 7 Jul '04  
QuestionThere is the function GetBody? PinmemberAlbert Pascual6:06 6 Aug '03  
Generali can't it Pinmemberoeurun3:11 6 Aug '03  
GeneralI can not seem to get the email headers, etc PinmemberJediman15:24 6 Jul '03  
GeneralRe: I can not seem to get the email headers, etc PinmemberJackieHoffman15:14 18 Nov '08  
GeneralWhy I can't get the infomations of my emails, such as sender, subject and date. Pinmemberrenchao9:25 27 Apr '03  
GeneralGood Job PinmemberJohn O'Byrne1:37 3 Jan '03  
GeneralThis code does not handle characters outside the ASCII PinmemberOceanSide9:06 5 Dec '02  

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.

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