PTLib
Version 2.10.4
|
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 * $Revision: 24461 $ 00030 * $Author: shorne $ 00031 * $Date: 2010-06-06 09:06:37 -0500 (Sun, 06 Jun 2010) $ 00032 */ 00033 00034 #ifndef PTLIB_MAIL_H 00035 #define PTLIB_MAIL_H 00036 00037 #ifdef P_USE_PRAGMA 00038 #pragma interface 00039 #endif 00040 00041 #if defined(_WIN32) && !defined(_WIN64) 00042 00043 # ifndef P_HAS_MAPI 00044 # define P_HAS_MAPI 1 00045 # endif 00046 00047 # ifndef P_HAS_CMC 00048 # define P_HAS_CMC 1 00049 # endif 00050 00051 # if P_HAS_MAPI 00052 # include <mapi.h> 00053 # endif 00054 00055 # if P_HAS_CMC 00056 # include <xcmc.h> 00057 # endif 00058 00059 #endif // _WIN32 00060 00061 00064 class PMail : public PObject 00065 { 00066 PCLASSINFO(PMail, PObject); 00067 00068 public: 00073 PMail(); 00074 00078 PMail( 00079 const PString & username, 00080 const PString & password 00081 ); 00082 00086 PMail( 00087 const PString & username, 00088 const PString & password, 00089 const PString & service 00094 ); 00095 00096 00097 virtual ~PMail(); 00098 /* Destroy the mail session, logging off the mail system if necessary. 00099 */ 00101 00109 PBoolean LogOn( 00110 const PString & username, 00111 const PString & password 00112 ); 00113 00119 PBoolean LogOn( 00120 const PString & username, 00121 const PString & password, 00122 const PString & service 00127 ); 00128 00134 virtual PBoolean LogOff(); 00135 00141 PBoolean IsLoggedOn() const; 00143 00152 PBoolean SendNote( 00153 const PString & recipient, 00154 const PString & subject, 00155 const char * body 00156 ); 00157 00164 PBoolean SendNote( 00165 const PString & recipient, 00166 const PString & subject, 00167 const char * body, 00168 const PStringList & attachments 00170 ); 00171 00178 PBoolean SendNote( 00179 const PString & recipient, 00180 const PStringList & carbonCopies, 00181 const PStringList & blindCarbons, 00182 const PString & subject, 00183 const char * body, 00184 const PStringList & attachments 00186 ); 00188 00196 PStringArray GetMessageIDs( 00197 PBoolean unreadOnly = true 00198 ); 00199 00201 struct Header { 00203 PString subject; 00205 PString originatorName; 00207 PString originatorAddress; 00209 PTime received; 00210 }; 00211 00217 PBoolean GetMessageHeader( 00218 const PString & id, 00219 Header & hdrInfo 00220 ); 00221 00238 PBoolean GetMessageBody( 00239 const PString & id, 00240 PString & body, 00241 PBoolean markAsRead = false 00242 ); 00243 00249 PBoolean GetMessageAttachments( 00250 const PString & id, 00251 PStringArray & filenames, 00252 PBoolean includeBody = false, 00253 PBoolean markAsRead = false 00254 ); 00255 00261 PBoolean MarkMessageRead( 00262 const PString & id 00263 ); 00264 00270 PBoolean DeleteMessage( 00271 const PString & id 00272 ); 00274 00277 00278 enum LookUpResult { 00280 UnknownUser, 00282 AmbiguousUser, 00284 ValidUser, 00286 LookUpError 00287 }; 00288 00295 LookUpResult LookUp( 00296 const PString & name, 00297 PString * fullName = NULL 00301 ); 00303 00312 int GetErrorCode() const; 00313 00320 PString GetErrorText() const; 00322 00323 00324 protected: 00325 void Construct(); 00326 // Common construction code. 00327 00329 PBoolean loggedOn; 00330 00331 00332 // Include platform dependent part of class 00333 #ifdef _WIN32 00334 #include "msos/ptlib/mail.h" 00335 #else 00336 #include "unix/ptlib/mail.h" 00337 #endif 00338 }; 00339 00340 00341 #endif // PTLIB_MAIL_H 00342 00343 00344 // End Of File ///////////////////////////////////////////////////////////////