Click here to Skip to main content
11,706,979 members (53,343 online)
Click here to Skip to main content

A POP3 class with WIN32 API (APOP Command support)

, 3 Jan 2003 150.7K 5.9K 72
Rate this:
Please Sign up or sign in to vote.
A POP3 class with WIN32 API

Sample Image - mail.jpg

Introduction

This is a simple POP3 class that can connect to a POP3 server and receive mail. Easy to use.

How to use

Create your project, add pop3.cpp and pop3.h to your project, then you can use it.

Step 1

  • Define a CPop3 variable in your class:

    CPop3 m_pop3handle;

Step 2

  • Create a POP3 connection:

    BOOL Create(LPCSTR pszHostName, int nPort);

Step 3

  • Connect to the POP3 server:

    BOOL Connect(LPCSTR pszUser, LPCSTR pszPassword);

Step 4

  • Get status form server:

    BOOL GetStat(CString *strStat);

  • Get mail list from server:

    BOOL GetMailList(CStringList *strResult);

  • Get a mail header:

    BOOL GetMailHeader(int nMailIndex , CString *strMailHeader);

  • Get a mail sender:

    BOOL GetMailSender(int nMailIndex, CString *strSender);

  • Get a mail receiver:

    BOOL GetMailReceiver(int nMailIndex, CString *strReceiver);

  • Get a mail subject:

    BOOL GetMailSubject(int nMainIndex, CString *strSubject);

  • Get a mail date:

    BOOL GetMailDate(int nMailIndex, CString *strDate);

  • Get a mail size:

    BOOL GetMailSize(int nMailIndex, long *lSize);

  • Get a mail body to memory:

    BOOL GetMail(int nMailIndex , CString *strMail);

  • Get a mail body to a temp file:

    BOOL GetMail(int nMailIndex, LPCSTR tmpfilename);

  • Delete a mail:

    BOOL DeleteMail(int nMailIndex);

  • Reset the mail list:

    BOOL ResetMail();

  • Get last error:

    BOOL GetLastError(CString *msg);

  • Get timeout setting:

    BOOL GetTimeOut(DWORD *dwTimeOut);

  • Set timeout:

    BOOL SetTimeOut(DWORD dwTimeOut);

  • Get the buffer size of receive:

    BOOL GetReceiveBufSize(long *lSize);

  • Set the buffer size of receive:

    BOOL SetReceiveBufSize(long lSize);

Step 5

  • Disconnect from the POP3 server:

    BOOL DisConnect();

Step 6

  • Close socket:

    BOOL Close();

Update

  • 2003.01.06

    Modify connect function:

    BOOL Connect(LPCSTR pszUser, LPCSTR pszPassword , BOOL bAPOPAuthentication);

    parameter 3 is authentication mode, if you want use APOP command, set it to TRUE, otherwise set it to FALSE.

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

Share

About the Author

Brandon G. WANG
Web Developer
Canada Canada
No Biography provided

You may also be interested in...

Comments and Discussions

 
Generalusing by meself Pin
Shi,Yudi10-Jun-10 19:07
memberShi,Yudi10-Jun-10 19:07 
GeneralRe: using by meself Pin
Brandon G. WANG5-Jul-10 5:28
memberBrandon G. WANG5-Jul-10 5:28 
QuestionIt's not support chinese? Pin
Member 461199318-Jan-10 20:21
memberMember 461199318-Jan-10 20:21 
AnswerRe: It's not support chinese? Pin
Shi,Yudi6-Jul-10 7:37
memberShi,Yudi6-Jul-10 7:37 
QuestionHow to check the NEW mail? (UNREAD mail) Pin
nonotoday12-Apr-06 22:43
membernonotoday12-Apr-06 22:43 
QuestionNTLM? Pin
Mindy68200423-Mar-06 9:36
memberMindy68200423-Mar-06 9:36 
QuestionWhat about attachments? Pin
Bashir Bakhshandeh29-Jan-06 19:03
memberBashir Bakhshandeh29-Jan-06 19:03 
Question,What about attachments? Pin
Bashir Bakhshandeh29-Jan-06 19:02
memberBashir Bakhshandeh29-Jan-06 19:02 
Questionwhy it can't work? Pin
encas15-Jan-06 15:26
memberencas15-Jan-06 15:26 
Generalwhen I use this class to download mail, I find it has a bug: it cannot download all mail. Pin
siduizhangjian@hotmail.com18-Oct-05 15:28
membersiduizhangjian@hotmail.com18-Oct-05 15:28 
QuestionHow I can get the content only? Pin
laohubinbin11-May-05 14:53
memberlaohubinbin11-May-05 14:53 
Questiononly one exe instant on windows? Pin
whatlink11-Nov-04 22:24
memberwhatlink11-Nov-04 22:24 
GeneralC++Builder Pin
superslam25-Jun-04 7:31
membersuperslam25-Jun-04 7:31 
QuestionServer too fast?? Pin
A-Wing9-Apr-04 10:18
memberA-Wing9-Apr-04 10:18 
AnswerRe: Server too fast?? Pin
Sig Hellene8-Jun-09 3:04
memberSig Hellene8-Jun-09 3:04 
GeneralThanks, it works well! Pin
MattyC3-Feb-04 11:56
memberMattyC3-Feb-04 11:56 
GeneralRe: Thanks, it works well! Pin
A-Wing7-Apr-04 3:32
memberA-Wing7-Apr-04 3:32 
GeneralRe: Thanks, it works well! Pin
MattyC7-Apr-04 3:44
memberMattyC7-Apr-04 3:44 
GeneralRe: Thanks, it works well! Pin
A-Wing9-Apr-04 10:29
memberA-Wing9-Apr-04 10:29 
GeneralRe: Thanks, it works well! Pin
Blake Miller29-Mar-05 12:11
memberBlake Miller29-Mar-05 12:11 
GeneralAttachements... Pin
JigarThakkar26-Nov-03 0:43
memberJigarThakkar26-Nov-03 0:43 
GeneralError: WINDOWS.H already included! Pin
getitforfun18-Sep-03 10:39
membergetitforfun18-Sep-03 10:39 
GeneralAvoid multiple definitions of winsock structs in MFC applications Pin
Jon Skaranger29-Jun-03 11:23
sussJon Skaranger29-Jun-03 11:23 
GeneralRe: Avoid multiple definitions of winsock structs in MFC applications Pin
Jon Skaranger29-Jun-03 11:29
sussJon Skaranger29-Jun-03 11:29 
GeneralI' m not able to use this class because of MFC Pin
Sharkky23-Mar-03 23:41
memberSharkky23-Mar-03 23:41 
GeneralRe: I' m not able to use this class because of MFC Pin
HippoTas13-Apr-03 21:09
memberHippoTas13-Apr-03 21:09 
GeneralRe: I' m not able to use this class because of MFC Pin
HippoTas13-Apr-03 23:02
memberHippoTas13-Apr-03 23:02 
GeneralNM Very good! THX, it saved me much time! Pin
Thomas Latuske7-Mar-03 11:03
memberThomas Latuske7-Mar-03 11:03 
GeneralComments Pin
Anatoly Ivasyuk21-Jan-03 6:08
memberAnatoly Ivasyuk21-Jan-03 6:08 
Questionhow about file attachments ? Pin
xuxiaofeng6-Jan-03 16:14
memberxuxiaofeng6-Jan-03 16:14 
AnswerRe: how about file attachments ? Pin
wanggang6-Jan-03 18:55
memberwanggang6-Jan-03 18:55 
GeneralRe: how about file attachments ? Pin
xuxiaofeng12-Jun-03 15:12
memberxuxiaofeng12-Jun-03 15:12 
GeneralServer please Pin
venu_pro9-Apr-04 3:55
sussvenu_pro9-Apr-04 3:55 
AnswerRe: how about file attachments ? Pin
HippoTas12-Jun-03 1:51
memberHippoTas12-Jun-03 1:51 
GeneralRe: how about file attachments ? Pin
xuxiaofeng12-Jun-03 15:11
memberxuxiaofeng12-Jun-03 15:11 
GeneralRe: how about file attachments ? Pin
Gajalakshmi Krishnan11-Apr-05 5:52
memberGajalakshmi Krishnan11-Apr-05 5:52 
GeneralA request Pin
giva4-Jan-03 22:54
membergiva4-Jan-03 22:54 
Good code (except the comments should be in english).

It would be nice if it implemented had an APOP authentication
method also. Not safe to send passwords in clear-text.
Ref RFC-1939/2828



Gisle V.
GeneralRe: A request Pin
wanggang5-Jan-03 20:15
memberwanggang5-Jan-03 20:15 
Generalsaving server and user name info Pin
Marc Clifton4-Jan-03 11:24
memberMarc Clifton4-Jan-03 11:24 

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
Web01 | 2.8.150819.1 | Last Updated 4 Jan 2003
Article Copyright 2003 by Brandon G. WANG
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid