Click here to Skip to main content
Licence 
First Posted 3 Jan 2003
Views 130,134
Bookmarked 66 times

A POP3 class with WIN32 API (APOP Command support)

By | 3 Jan 2003 | Article
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

About the Author

Brandon G. WANG

Web Developer

Canada Canada

Member



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
Generalusing by meself PinmemberShi,Yudi19:07 10 Jun '10  
GeneralRe: using by meself PinmemberBrandon G. WANG5:28 5 Jul '10  
QuestionIt's not support chinese? PinmemberMember 461199320:21 18 Jan '10  
AnswerRe: It's not support chinese? PinmemberShi,Yudi7:37 6 Jul '10  
QuestionHow to check the NEW mail? (UNREAD mail) Pinmembernonotoday22:43 12 Apr '06  
QuestionNTLM? PinmemberMindy6820049:36 23 Mar '06  
QuestionWhat about attachments? PinmemberBashir Bakhshandeh19:03 29 Jan '06  
Question,What about attachments? PinmemberBashir Bakhshandeh19:02 29 Jan '06  
Questionwhy it can't work? Pinmemberencas15:26 15 Jan '06  
Generalwhen I use this class to download mail, I find it has a bug: it cannot download all mail. Pinmembersiduizhangjian@hotmail.com15:28 18 Oct '05  
QuestionHow I can get the content only? Pinmemberlaohubinbin14:53 11 May '05  
Questiononly one exe instant on windows? Pinmemberwhatlink22:24 11 Nov '04  
GeneralC++Builder Pinmembersuperslam7:31 25 Jun '04  
QuestionServer too fast?? PinmemberA-Wing10:18 9 Apr '04  
AnswerRe: Server too fast?? PinmemberSig Hellene3:04 8 Jun '09  
GeneralThanks, it works well! PinmemberMattyC11:56 3 Feb '04  
GeneralRe: Thanks, it works well! PinmemberA-Wing3:32 7 Apr '04  
GeneralRe: Thanks, it works well! PinmemberMattyC3:44 7 Apr '04  
GeneralRe: Thanks, it works well! PinmemberA-Wing10:29 9 Apr '04  
GeneralRe: Thanks, it works well! PinmemberBlake Miller12:11 29 Mar '05  
GeneralAttachements... PinmemberJigarThakkar0:43 26 Nov '03  
GeneralError: WINDOWS.H already included! Pinmembergetitforfun10:39 18 Sep '03  
GeneralAvoid multiple definitions of winsock structs in MFC applications PinsussJon Skaranger11:23 29 Jun '03  
GeneralRe: Avoid multiple definitions of winsock structs in MFC applications PinsussJon Skaranger11:29 29 Jun '03  
GeneralI' m not able to use this class because of MFC PinmemberSharkky23:41 23 Mar '03  

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