mail.h
Go to the documentation of this file.
/*
* mail.h
*
* Electronic Mail abstraction class.
*
* Portable Windows Library
*
* Copyright (c) 1993-1998 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Revision: 24461 $
* $Author: shorne $
* $Date: 2010-06-06 09:06:37 -0500 (Sun, 06 Jun 2010) $
*/
#ifndef PTLIB_MAIL_H
#define PTLIB_MAIL_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#if defined(_WIN32) && !defined(_WIN64)
# ifndef P_HAS_MAPI
# define P_HAS_MAPI 1
# endif
# ifndef P_HAS_CMC
# define P_HAS_CMC 1
# endif
# if P_HAS_MAPI
# include <mapi.h>
# endif
# if P_HAS_CMC
# include <xcmc.h>
# endif
#endif // _WIN32
class PMail : public PObject
{
PCLASSINFO(PMail, PObject);
public:
PMail();
PMail(
const PString & username,
const PString & password
);
PMail(
const PString & username,
const PString & password,
const PString & service
);
virtual ~PMail();
/* Destroy the mail session, logging off the mail system if necessary.
*/
PBoolean LogOn(
const PString & username,
const PString & password
);
PBoolean LogOn(
const PString & username,
const PString & password,
const PString & service
);
virtual PBoolean LogOff();
PBoolean IsLoggedOn() const;
PBoolean SendNote(
const PString & recipient,
const PString & subject,
const char * body
);
PBoolean SendNote(
const PString & recipient,
const PString & subject,
const char * body,
const PStringList & attachments
);
PBoolean SendNote(
const PString & recipient,
const PStringList & carbonCopies,
const PStringList & blindCarbons,
const PString & subject,
const char * body,
const PStringList & attachments
);
PStringArray GetMessageIDs(
PBoolean unreadOnly = true
);
struct Header {
PString subject;
PString originatorName;
PString originatorAddress;
PTime received;
};
PBoolean GetMessageHeader(
const PString & id,
Header & hdrInfo
);
PBoolean GetMessageBody(
const PString & id,
PString & body,
PBoolean markAsRead = false
);
PBoolean GetMessageAttachments(
const PString & id,
PStringArray & filenames,
PBoolean includeBody = false,
PBoolean markAsRead = false
);
PBoolean MarkMessageRead(
const PString & id
);
PBoolean DeleteMessage(
const PString & id
);
enum LookUpResult {
UnknownUser,
AmbiguousUser,
ValidUser,
LookUpError
};
LookUpResult LookUp(
const PString & name,
PString * fullName = NULL
);
int GetErrorCode() const;
PString GetErrorText() const;
protected:
void Construct();
// Common construction code.
PBoolean loggedOn;
// Include platform dependent part of class
#ifdef _WIN32
#include "msos/ptlib/mail.h"
#else
#include "unix/ptlib/mail.h"
#endif
};
#endif // PTLIB_MAIL_H
// End Of File ///////////////////////////////////////////////////////////////
PMail::GetErrorCode
int GetErrorCode() const
Get the internal error code for the last error by a function in this mail session.
PMail::IsLoggedOn
PBoolean IsLoggedOn() const
Determine if the mail session is active and logged into the mail system.
PMail::LookUpResult
LookUpResult
Result of a lookup operation with the LookUp() function.
Definition: mail.h:278
PMail::GetErrorText
PString GetErrorText() const
Get the internal error description for the last error by a function in this mail session.
PTime
This class defines an absolute time and date.
Definition: ptime.h:53
PMail::LookUp
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.
PMail::loggedOn
PBoolean loggedOn
Flag indicating the session is active.
Definition: mail.h:329
PMail::Header::received
PTime received
Time message received.
Definition: mail.h:209
PMail::LookUpError
An error occurred during the look up.
Definition: mail.h:286
PStringArray
This is an array collection class of PString objects.
Definition: pstring.h:2024
PMail::PMail
PMail()
Create a mail session.
PMail::GetMessageHeader
PBoolean GetMessageHeader(const PString &id, Header &hdrInfo)
Get the header information for a message.
PBoolean
BOOL PBoolean
Definition: object.h:102
PMail::Header
Message header for each mail item.
Definition: mail.h:201
PString
The character string class.
Definition: pstring.h:108
PMail::Header::subject
PString subject
Subject for message.
Definition: mail.h:203
PMail::~PMail
virtual ~PMail()
PMail::MarkMessageRead
PBoolean MarkMessageRead(const PString &id)
Mark the message as read.
PMail::ValidUser
User is a valid, unique name in mail system.
Definition: mail.h:284
PStringList
This is a list collection class of PString objects.
Definition: pstring.h:2184
PMail::Construct
void Construct()
PMail::DeleteMessage
PBoolean DeleteMessage(const PString &id)
Delete the message from the system.
PMail::LogOff
virtual PBoolean LogOff()
Log off from the mail system.
PMail::GetMessageAttachments
PBoolean GetMessageAttachments(const PString &id, PStringArray &filenames, PBoolean includeBody=false, PBoolean markAsRead=false)
Get all of the attachments for a message as disk files.
PMail::UnknownUser
User name is unknown in mail system.
Definition: mail.h:280
PMail::AmbiguousUser
User is ambiguous in mail system.
Definition: mail.h:282
PMail::SendNote
PBoolean SendNote(const PString &recipient, const PString &subject, const char *body)
Send a new simple mail message.
PMail::LogOn
PBoolean LogOn(const PString &username, const PString &password)
Attempt to log on to the mail system using the parameters provided.
PMail::Header::originatorAddress
PString originatorAddress
Return address of message originator.
Definition: mail.h:207
PMail::GetMessageBody
PBoolean GetMessageBody(const PString &id, PString &body, PBoolean markAsRead=false)
Get the body text for a message into the body string parameter.
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PMail
This class establishes a mail session with the platforms mail system.
Definition: mail.h:64
PMail::GetMessageIDs
PStringArray GetMessageIDs(PBoolean unreadOnly=true)
Get a list of ID strings for all messages in the mail box.
PMail::Header::originatorName
PString originatorName
Full name of message originator.
Definition: mail.h:205