Currently, EMAIL is widely used on the Internet. About half of all TCP connection lines are used to send and receive emails. Therefore, it is impossible for many network applications to leave the POP3 protocol.
In addition, many EMAIL systems use the SMTP protocol as the sending protocol and POP3 protocol as the receiving protocol. For more information about the two Protocols, see RCF821 (about SMTP) and RCF1225 (about POP3 ). Although in WINDOWS, an MAPI application manages emails, it is not powerful enough to directly process some EMAIL services. Therefore, I wrote a C ++ class about POP3 protocol. In this class, I also used CSocket as a class member (which seems a bit unimaginable, we can use it during connection. In addition, some functions of the POP class are similar to some commands in POP3 protocol. The following code is used:
/*--------------------------------------------------------------------
Pop. h: main header file for the POP application
-----------------------------------------------------------------------*/
# If! Defined (afx_pop_h1_a44b38b6_697c_11d1_881e_1_1c3025811_included _)
# Define afx_pop_h1_a44b38b6_697c_11d1_881e_1_1c3025811_encoded _
# Define CONNECTION_CHECK 0
# Define USER_CHECK1
# Define PASSWORD_CHECK 2
# Define QUIT_CHECK3
# Define DELETE_CHECK 4
# Define RSET_CHECK5
# Define STAT_CHECK6
# Define NOOP_CHECK7
# Define LIST_CHECK8
# Define RETR_CHECK9
//////////////////////////////////////// /////////////////////////////////////
Class CPop
{
Public:
BOOL List ();
CWordArray m_SizeOfMsg;
CString GetErrorMessage ();// If there is any error this will return it method
CString GetPassword ();// Getting Password stored in class
Void SetPassword (CString & Password );// Setting Password in class
CString GetUser ();// Getting user name stored in class
Void SetUser (CString & User );// Setting user name in class
CString GetHost (); // Getting Host name (email server name) stored in class
Void SetHost (CString & Host );// Setting Host name (email server name) in class
BOOL Connect ();// Connecting to email server
Int GetTotalMailSize ();// It returns the Total Mail Size
Int GetNumberOfMails ();// It return the number of mails
CString GetMsgContents ();
BOOL Statistics ();// Issue the STAT command on email server
BOOL Retrieve (int MsgNumber ); // Getting any participates mail message
BOOL Reset ();// Issue the reset command on email server
IntGetMessageSize (int MsgNumber );// Return a size of any participant mail
BOOL Noop ();