4 * Electronic Mail abstraction class.
6 * Portable Windows Library
8 * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
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/
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
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25 * All Rights Reserved.
27 * Contributor(s): ______________________________________.
30 * Revision 1.13 2003/09/17 05:41:58 csoutheren
31 * Removed recursive includes
33 * Revision 1.12 2003/09/17 01:18:02 csoutheren
34 * Removed recursive include file system and removed all references
35 * to deprecated coooperative threading support
37 * Revision 1.11 2002/09/16 01:08:59 robertj
38 * Added #define so can select if #pragma interface/implementation is used on
39 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
41 * Revision 1.10 2001/05/22 12:49:32 robertj
42 * Did some seriously wierd rewrite of platform headers to eliminate the
43 * stupid GNU compiler warning about braces not matching.
45 * Revision 1.9 1999/03/09 02:59:50 robertj
46 * Changed comments to doc++ compatible documentation.
48 * Revision 1.8 1999/02/16 08:12:00 robertj
49 * MSVC 6.0 compatibility changes.
51 * Revision 1.7 1999/02/10 13:20:53 robertj
52 * Added ability to have attachments in mail messages.
54 * Revision 1.6 1998/09/23 06:20:51 robertj
55 * Added open source copyright license.
57 * Revision 1.5 1997/05/16 12:14:08 robertj
58 * Added BCC capability to send mail.
60 * Revision 1.4 1995/07/02 01:19:46 robertj
61 * Change GetMessageBidy to return BOOL and have body string as
62 * parameter, due to slight change in semantics for large bodies.
64 * Revision 1.3 1995/06/17 00:42:22 robertj
65 * Added mail reading interface.
66 * Changed name to simply PMail
68 * Revision 1.2 1995/04/01 08:27:57 robertj
71 * Revision 1.1 1995/03/14 12:44:11 robertj
104 /**This class establishes a mail session with the platforms mail system.
106 class PMail
: public PObject
108 PCLASSINFO(PMail
, PObject
);
111 /**@name Construction */
113 /**Create a mail session. It is initially not logged in.
117 /**Create a mail session.
118 Attempt to log in using the parameters provided.
121 const PString
& username
, /// User withing mail system to use.
122 const PString
& password
/// Password for user in mail system.
125 /**Create a mail session.
126 Attempt to log in using the parameters provided.
129 const PString
& username
, /// User withing mail system to use.
130 const PString
& password
, /// Password for user in mail system.
131 const PString
& service
132 /**A platform dependent string indicating the location of the underlying
133 messaging service, eg the path to a message store or node name of the
140 /* Destroy the mail session, logging off the mail system if necessary.
144 /**@name Log in/out functions */
146 /**Attempt to log on to the mail system using the parameters provided.
149 TRUE if successfully logged on.
152 const PString
& username
, /// User withing mail system to use.
153 const PString
& password
/// Password for user in mail system.
156 /**Attempt to log on to the mail system using the parameters provided.
159 TRUE if successfully logged on.
162 const PString
& username
, /// User withing mail system to use.
163 const PString
& password
, /// Password for user in mail system.
164 const PString
& service
165 /**A platform dependent string indicating the location of the underlying
166 messaging service, eg the path to a message store or node name of the
171 /**Log off from the mail system.
174 TRUE if successfully logged off.
176 virtual BOOL
LogOff();
178 /**Determine if the mail session is active and logged into the mail system.
181 TRUE if logged into the mail system.
183 BOOL
IsLoggedOn() const;
186 /**@name Send message functions */
188 /**Send a new simple mail message.
191 TRUE if the mail message was successfully queued. Note that this does
192 {\bf not} mean that it has been delivered.
195 const PString
& recipient
, /// Name of recipient of the mail message.
196 const PString
& subject
, /// Subject name for the mail message.
197 const char * body
/// Text body of the mail message.
200 /**Send a new simple mail message.
203 TRUE if the mail message was successfully queued. Note that this does
204 {\bf not} mean that it has been delivered.
207 const PString
& recipient
, /// Name of recipient of the mail message.
208 const PString
& subject
, /// Subject name for the mail message.
209 const char * body
, /// Text body of the mail message.
210 const PStringList
& attachments
211 /// List of files to attach to the mail message.
214 /**Send a new simple mail message.
217 TRUE if the mail message was successfully queued. Note that this does
218 {\bf not} mean that it has been delivered.
221 const PString
& recipient
, /// Name of recipient of the mail message.
222 const PStringList
& carbonCopies
, /// Name of CC recipients.
223 const PStringList
& blindCarbons
, /// Name of BCC recipients.
224 const PString
& subject
, /// Subject name for the mail message.
225 const char * body
, /// Text body of the mail message.
226 const PStringList
& attachments
227 /// List of files to attach to the mail message.
231 /**@name Read message functions */
233 /**Get a list of ID strings for all messages in the mail box.
236 An array of ID strings.
238 PStringArray
GetMessageIDs(
239 BOOL unreadOnly
= TRUE
/// Only get the IDs for unread messages.
242 /// Message header for each mail item.
244 /// Subject for message.
246 /// Full name of message originator.
247 PString originatorName
;
248 /// Return address of message originator.
249 PString originatorAddress
;
250 /// Time message received.
254 /**Get the header information for a message.
257 TRUE if header information was successfully obtained.
259 BOOL
GetMessageHeader(
260 const PString
& id
, /// Identifier of message to get header.
261 Header
& hdrInfo
/// Header info for the message.
264 /**Get the body text for a message into the #body# string
267 Note that if the body text for the mail message is very large, the
268 function will return FALSE. To tell between an error getting the message
269 body and having a large message body the #GetErrorCode()# function
272 To get a large message body, the #GetMessageAttachments()# should
273 be used with the #includeBody# parameter set to TRUE so that
274 the message body is placed into a disk file.
277 TRUE if the body text was retrieved, FALSE if the body was too large or
278 some other error occurred.
281 const PString
& id
, /// Identifier of message to get body.
282 PString
& body
, /// Body text of mail message.
283 BOOL markAsRead
= FALSE
/// Mark the message as read.
286 /**Get all of the attachments for a message as disk files.
289 TRUE if attachments were successfully obtained.
291 BOOL
GetMessageAttachments(
292 const PString
& id
, /// Identifier of message to get attachments.
293 PStringArray
& filenames
, /// File names for each attachment.
294 BOOL includeBody
= FALSE
, /// Include the message body as first attachment
295 BOOL markAsRead
= FALSE
/// Mark the message as read
298 /**Mark the message as read.
301 TRUE if message was successfully marked as read.
303 BOOL
MarkMessageRead(
304 const PString
& id
/// Identifier of message to get header.
307 /**Delete the message from the system.
310 TRUE if message was successfully deleted.
313 const PString
& id
/// Identifier of message to get header.
317 /**@name User look up functions */
319 /// Result of a lookup operation with the #LookUp()# function.
321 /// User name is unknown in mail system.
323 /// User is ambiguous in mail system.
325 /// User is a valid, unique name in mail system.
327 /// An error occurred during the look up
331 /**Look up the specified name and verify that they are a valid address in
335 result of the name lookup.
338 const PString
& name
, /// Name to look up.
339 PString
* fullName
= NULL
340 /**String to receive full name of user passed in #name#. If
341 NULL then the full name is {\bf not} returned.
346 /**@name Error functions */
348 /**Get the internal error code for the last error by a function in this
352 integer error code for last operation.
354 int GetErrorCode() const;
356 /**Get the internal error description for the last error by a function in
360 string error text for last operation.
362 PString
GetErrorText() const;
368 // Common construction code.
370 /// Flag indicating the session is active.
374 // Include platform dependent part of class
376 #include "msos/ptlib/mail.h"
378 #include "unix/ptlib/mail.h"
384 // End Of File ///////////////////////////////////////////////////////////////