65.9K
CodeProject is changing. Read more.
Home

A POP3 class with WIN32 API (APOP Command support)

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.69/5 (21 votes)

Jan 4, 2003

1 min read

viewsIcon

190781

downloadIcon

6760

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.

OSZAR »