Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5382205
  • 博文数量: 671
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 7310
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-14 09:56
文章分类

全部博文(671)

文章存档

2011年(1)

2010年(2)

2009年(24)

2008年(271)

2007年(319)

2006年(54)

我的朋友

分类: C/C++

2008-08-26 14:03:50

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

阅读(569) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~