PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mail.h
Go to the documentation of this file.
1 /*
2  * mail.h
3  *
4  * Electronic Mail abstraction class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  */
29 
30 #ifndef PTLIB_MAIL_H
31 #define PTLIB_MAIL_H
32 
33 #ifdef P_USE_PRAGMA
34 #pragma interface
35 #endif
36 
37 #if defined(_WIN32) && !defined(_WIN64)
38 
39 # if _MSC_VER < 1700
40 
41 # ifndef P_HAS_MAPI
42 # define P_HAS_MAPI 1
43 # endif
44 
45 # ifndef P_HAS_CMC
46 # define P_HAS_CMC 1
47 # endif
48 
49 # endif
50 
51 # if P_HAS_MAPI
52 # include <mapi.h>
53 # endif
54 
55 # if P_HAS_CMC
56 # include <xcmc.h>
57 # endif
58 
59 #endif // _WIN32
60 
61 
64 class PMail : public PObject
65 {
66  PCLASSINFO(PMail, PObject);
67 
68  public:
73  PMail();
74 
78  PMail(
79  const PString & username,
80  const PString & password
81  );
82 
86  PMail(
87  const PString & username,
88  const PString & password,
89  const PString & service
94  );
95 
96 
97  virtual ~PMail();
98  /* Destroy the mail session, logging off the mail system if necessary.
99  */
101 
109  PBoolean LogOn(
110  const PString & username,
111  const PString & password
112  );
113 
119  PBoolean LogOn(
120  const PString & username,
121  const PString & password,
122  const PString & service
127  );
128 
134  virtual PBoolean LogOff();
135 
141  PBoolean IsLoggedOn() const;
143 
153  const PString & recipient,
154  const PString & subject,
155  const char * body
156  );
157 
165  const PString & recipient,
166  const PString & subject,
167  const char * body,
168  const PStringList & attachments
170  );
171 
179  const PString & recipient,
180  const PStringList & carbonCopies,
181  const PStringList & blindCarbons,
182  const PString & subject,
183  const char * body,
184  const PStringList & attachments
186  );
188 
197  PBoolean unreadOnly = true
198  );
199 
201  struct Header {
210  };
211 
218  const PString & id,
219  Header & hdrInfo
220  );
221 
239  const PString & id,
240  PString & body,
241  PBoolean markAsRead = false
242  );
243 
250  const PString & id,
251  PStringArray & filenames,
252  PBoolean includeBody = false,
253  PBoolean markAsRead = false
254  );
255 
262  const PString & id
263  );
264 
271  const PString & id
272  );
274 
277  enum LookUpResult {
287  };
288 
296  const PString & name,
297  PString * fullName = NULL
301  );
303 
312  int GetErrorCode() const;
313 
320  PString GetErrorText() const;
322 
323 
324  protected:
325  void Construct();
326  // Common construction code.
327 
330 
331 
332 // Include platform dependent part of class
333 #ifdef _WIN32
334 #include "msos/ptlib/mail.h"
335 #else
336 #include "unix/ptlib/mail.h"
337 #endif
338 };
339 
340 
341 #endif // PTLIB_MAIL_H
342 
343 
344 // End Of File ///////////////////////////////////////////////////////////////
int GetErrorCode() const
Get the internal error code for the last error by a function in this mail session.
PBoolean IsLoggedOn() const
Determine if the mail session is active and logged into the mail system.
LookUpResult
Result of a lookup operation with the LookUp() function.
Definition: mail.h:278
PString GetErrorText() const
Get the internal error description for the last error by a function in this mail session.
This class defines an absolute time and date.
Definition: ptime.h:49
LookUpResult LookUp(const PString &name, PString *fullName=NULL)
Look up the specified name and verify that they are a valid address in the mail system.
PBoolean loggedOn
Flag indicating the session is active.
Definition: mail.h:329
PTime received
Time message received.
Definition: mail.h:209
An error occurred during the look up.
Definition: mail.h:286
This is an array collection class of PString objects.
Definition: pstring.h:2365
PMail()
Create a mail session.
PBoolean GetMessageHeader(const PString &id, Header &hdrInfo)
Get the header information for a message.
Message header for each mail item.
Definition: mail.h:201
bool PBoolean
Definition: object.h:174
The character string class.
Definition: pstring.h:108
PString subject
Subject for message.
Definition: mail.h:203
virtual ~PMail()
PBoolean MarkMessageRead(const PString &id)
Mark the message as read.
User is a valid, unique name in mail system.
Definition: mail.h:284
This is a list collection class of PString objects.
Definition: pstring.h:2562
void Construct()
PBoolean DeleteMessage(const PString &id)
Delete the message from the system.
virtual PBoolean LogOff()
Log off from the mail system.
PBoolean GetMessageAttachments(const PString &id, PStringArray &filenames, PBoolean includeBody=false, PBoolean markAsRead=false)
Get all of the attachments for a message as disk files.
User name is unknown in mail system.
Definition: mail.h:280
User is ambiguous in mail system.
Definition: mail.h:282
PBoolean SendNote(const PString &recipient, const PString &subject, const char *body)
Send a new simple mail message.
PBoolean LogOn(const PString &username, const PString &password)
Attempt to log on to the mail system using the parameters provided.
PString originatorAddress
Return address of message originator.
Definition: mail.h:207
PBoolean GetMessageBody(const PString &id, PString &body, PBoolean markAsRead=false)
Get the body text for a message into the body string parameter.
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
This class establishes a mail session with the platforms mail system.
Definition: mail.h:64
PStringArray GetMessageIDs(PBoolean unreadOnly=true)
Get a list of ID strings for all messages in the mail box.
PString originatorName
Full name of message originator.
Definition: mail.h:205