mail.h

Go to the documentation of this file.
00001 /*
00002  * mail.h
00003  *
00004  * Electronic Mail abstraction class.
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
00025  * All Rights Reserved.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: mail.h,v $
00030  * Revision 1.14  2005/11/25 03:43:47  csoutheren
00031  * Fixed function argument comments to be compatible with Doxygen
00032  *
00033  * Revision 1.13  2003/09/17 05:41:58  csoutheren
00034  * Removed recursive includes
00035  *
00036  * Revision 1.12  2003/09/17 01:18:02  csoutheren
00037  * Removed recursive include file system and removed all references
00038  * to deprecated coooperative threading support
00039  *
00040  * Revision 1.11  2002/09/16 01:08:59  robertj
00041  * Added #define so can select if #pragma interface/implementation is used on
00042  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00043  *
00044  * Revision 1.10  2001/05/22 12:49:32  robertj
00045  * Did some seriously wierd rewrite of platform headers to eliminate the
00046  *   stupid GNU compiler warning about braces not matching.
00047  *
00048  * Revision 1.9  1999/03/09 02:59:50  robertj
00049  * Changed comments to doc++ compatible documentation.
00050  *
00051  * Revision 1.8  1999/02/16 08:12:00  robertj
00052  * MSVC 6.0 compatibility changes.
00053  *
00054  * Revision 1.7  1999/02/10 13:20:53  robertj
00055  * Added ability to have attachments in mail messages.
00056  *
00057  * Revision 1.6  1998/09/23 06:20:51  robertj
00058  * Added open source copyright license.
00059  *
00060  * Revision 1.5  1997/05/16 12:14:08  robertj
00061  * Added BCC capability to send mail.
00062  *
00063  * Revision 1.4  1995/07/02 01:19:46  robertj
00064  * Change GetMessageBidy to return BOOL and have body string as
00065  *   parameter, due to slight change in semantics for large bodies.
00066  *
00067  * Revision 1.3  1995/06/17 00:42:22  robertj
00068  * Added mail reading interface.
00069  * Changed name to simply PMail
00070  *
00071  * Revision 1.2  1995/04/01 08:27:57  robertj
00072  * Added GUI support.
00073  *
00074  * Revision 1.1  1995/03/14  12:44:11  robertj
00075  * Initial revision
00076  *
00077  */
00078 
00079 #ifndef _PMAIL
00080 #define _PMAIL
00081 
00082 #ifdef P_USE_PRAGMA
00083 #pragma interface
00084 #endif
00085 
00086 #ifdef _WIN32
00087 
00088 #  ifndef P_HAS_MAPI
00089 #  define P_HAS_MAPI 1
00090 #  endif
00091 
00092 #  ifndef P_HAS_CMC
00093 #  define P_HAS_CMC 1
00094 #  endif
00095 
00096 #  if P_HAS_MAPI
00097 #  include <mapi.h>
00098 #  endif
00099 
00100 #  if P_HAS_CMC
00101 #  include <xcmc.h>
00102 #  endif
00103 
00104 #endif  // _WIN32
00105 
00106 
00109 class PMail : public PObject
00110 {
00111   PCLASSINFO(PMail, PObject);
00112 
00113   public:
00118     PMail();
00119 
00123     PMail(
00124       const PString & username,  
00125       const PString & password   
00126     );
00127 
00131     PMail(
00132       const PString & username,  
00133       const PString & password,  
00134       const PString & service
00139     );
00140 
00141 
00142     virtual ~PMail();
00143     /* Destroy the mail session, logging off the mail system if necessary.
00144      */
00146 
00154     BOOL LogOn(
00155       const PString & username,  
00156       const PString & password   
00157     );
00158 
00164     BOOL LogOn(
00165       const PString & username,  
00166       const PString & password,  
00167       const PString & service
00172     );
00173 
00179     virtual BOOL LogOff();
00180 
00186     BOOL IsLoggedOn() const;
00188 
00197     BOOL SendNote(
00198       const PString & recipient,  
00199       const PString & subject,    
00200       const char * body           
00201     );
00202 
00209     BOOL SendNote(
00210       const PString & recipient,  
00211       const PString & subject,    
00212       const char * body,          
00213       const PStringList & attachments
00215     );
00216 
00223     BOOL SendNote(
00224       const PString & recipient,  
00225       const PStringList & carbonCopies, 
00226       const PStringList & blindCarbons, 
00227       const PString & subject,        
00228       const char * body,              
00229       const PStringList & attachments
00231     );
00233 
00241     PStringArray GetMessageIDs(
00242       BOOL unreadOnly = TRUE    
00243     );
00244 
00246     struct Header {
00248       PString  subject;           
00250       PString  originatorName;    
00252       PString  originatorAddress; 
00254       PTime    received;          
00255     };
00256 
00262     BOOL GetMessageHeader(
00263       const PString & id,      
00264       Header & hdrInfo         
00265     );
00266 
00283     BOOL GetMessageBody(
00284       const PString & id,      
00285       PString & body,          
00286       BOOL markAsRead = FALSE  
00287     );
00288 
00294     BOOL GetMessageAttachments(
00295       const PString & id,       
00296       PStringArray & filenames, 
00297       BOOL includeBody = FALSE, 
00298       BOOL markAsRead = FALSE   
00299     );
00300 
00306     BOOL MarkMessageRead(
00307       const PString & id      
00308     );
00309 
00315     BOOL DeleteMessage(
00316       const PString & id      
00317     );
00319 
00322 
00323     enum LookUpResult {
00325       UnknownUser,    
00327       AmbiguousUser,  
00329       ValidUser,      
00331       LookUpError     
00332     };
00333 
00340     LookUpResult LookUp(
00341       const PString & name,  
00342       PString * fullName = NULL
00346     );
00348 
00357     int GetErrorCode() const;
00358 
00365     PString GetErrorText() const;
00367 
00368 
00369   protected:
00370     void Construct();
00371     // Common construction code.
00372 
00374     BOOL loggedOn;
00375 
00376 
00377 // Include platform dependent part of class
00378 #ifdef _WIN32
00379 #include "msos/ptlib/mail.h"
00380 #else
00381 #include "unix/ptlib/mail.h"
00382 #endif
00383 };
00384 
00385 #endif
00386 
00387 // End Of File ///////////////////////////////////////////////////////////////

Generated on Fri Mar 7 06:25:02 2008 for PTLib by  doxygen 1.5.1