home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2002 September / PCPlus_193_Laplink2000.iso / Prog / C++ / EmailDemo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-04-07  |  1.2 KB  |  45 lines

  1. // This is the main project file for VC++ application project 
  2. // generated using an Application Wizard.
  3.  
  4. #include "stdafx.h"
  5. #using <mscorlib.dll>
  6. #using <system.dll>
  7.  
  8. using namespace System;
  9.  
  10. #include "Pop3Client.h"
  11.  
  12. // This is the entry point for this application
  13.  
  14. int main(int argc, char *argv[ ])
  15. {
  16.     Console::WriteLine();
  17.  
  18.     // Check parameters.
  19.     if(argc != 4)
  20.     {
  21.         Console::WriteLine (String::Format ("Usage: {0} servername username password", new String(argv[0])));
  22.         Console::Write ("Press Enter to continue");
  23.         Console::ReadLine();
  24.         return 0;
  25.     }
  26.  
  27.     // Create POP3Client object.
  28.     CPOP3Client* POP3 = new CPOP3Client();
  29.  
  30.     // Set properties from command line.
  31.     POP3->ServerName = new String(argv[1]);
  32.     POP3->UserName = new String(argv[2]);
  33.     POP3->Password = new String(argv[3]);
  34.  
  35.     // Get number of messages in the mailbox.
  36.     int count = POP3->NumberOfMessages;
  37.  
  38.     // If -1 returned, error occurred, then print error message.
  39.     if (count < 0) Console::WriteLine (String::Concat ("Error: ", POP3->Status));
  40.     else Console::WriteLine (String::Format ("You have {0} messages in your mailbox", __box (count)));
  41.  
  42.     Console::Write ("Press Enter to continue");
  43.     Console::ReadLine();
  44.     return 0;
  45. }