分类: C/C++
2008-08-26 14:03:50
This is a simple POP3 class that can connect to a POP3 server and receive mail. Easy to use.
Create your project, add pop3.cpp and pop3.h to your project, then you can use it.
CPop3
variable in your class:
CPop3 m_pop3handle;
BOOL Create(LPCSTR pszHostName, int nPort);
BOOL Connect(LPCSTR pszUser, LPCSTR pszPassword);
BOOL GetStat(CString *strStat);
BOOL GetMailList(CStringList *strResult);
BOOL GetMailHeader(int nMailIndex , CString *strMailHeader);
BOOL GetMailSender(int nMailIndex, CString *strSender);
BOOL GetMailReceiver(int nMailIndex, CString *strReceiver);
BOOL GetMailSubject(int nMainIndex, CString *strSubject);
BOOL GetMailDate(int nMailIndex, CString *strDate);
BOOL GetMailSize(int nMailIndex, long *lSize);
BOOL GetMail(int nMailIndex , CString *strMail);
BOOL GetMail(int nMailIndex, LPCSTR tmpfilename);
BOOL DeleteMail(int nMailIndex);
BOOL ResetMail();
BOOL GetLastError(CString *msg);
BOOL GetTimeOut(DWORD *dwTimeOut);
BOOL SetTimeOut(DWORD dwTimeOut);
BOOL GetReceiveBufSize(long *lSize);
BOOL SetReceiveBufSize(long lSize);
BOOL DisConnect();
BOOL Close();
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
.