img img img img img  
Home Development Partners Resellers About  
img   img The Messaging API is a COM-like API that provides access to the contents of messaging stores. "Extended MAPI in Delphi" is a package providing access to Outlook-compatible objects through a COM-based API. Using MAPI, a program can connect to a MAPI store, and then perform operations against that store.
img Extended MAPI in Delphi
 
 

Delphi MAPI Examples - Extended MAPI in DELPHI

DELPHI 6, 7, 2005, 2006 win32, 2007, 2009, 2010, XE, XE2 - XE8, Seattle/Berlin/Tokyo (x32/x64) compatibles

Microsoft Exchange Server 5.5/2000/2003/2007/2010/2013 compatibles
Microsoft Outlook 97/98/2000/2002/2003/2007/2010/2013/2016 (x32/x64) compatibles

We provide source code - not VCL


The Extended MAPI is one of the first COM technologies provided by Microsoft. Extended MAPI is core API for Microsoft Exchange Server, Microsoft Outlook, CDO, messaging, etc.
We provide lots of examples, which demonstrates how inside DELPHI you can get the Extended MAPI power in your hands. They are grouped as "package" of simple applications and library. Our "library" includes "one file" ExtendedMAPI unit, some useful utility functions which you can find inside MAPIUtils.pas, and unique translation of EDK (Exchange Development Kit). You will have in your hands, more that 70 Interfaces, few hundreds procedures and functions, thousands constants, structures, etc  - all of them described inside MSDN or PSDK. For most of them, you can use shipped with Delphi help (excluding EDK).
We strongly recommends MSDN as the primary help system for Extended MAPI and EDK.

  Example # 1
Log in Microsoft Exchange Server and Query User Identity

The Extended MAPI is one of the first COM technologies provided by Microsoft.
To use any of the extended MAPI functions and/or interfaces (with very few exceptions), before we do anything, we should initialize the Extended MAPI subsystem.
For this purpose Microsoft provides the MapiInitialize function.
Through this function MAPI initializes the COM system by calling CoInitialize internally.

In this example:

How to

  • Use MAPInitialize
  • Use MAPIINIT_0 structure with MAPIInitialize
  • Use MAPIInitialize when CoInitializeEx is called with the COINIT_MULTITHREADED
  • Use MAPILogonEx
  • Control how logon is performed
  • Query Identity
  • Use MAPIAllocateBuffer
  • Use MAPIFreeBuffer
  • Use IMAPIProp
  • Use  MAPIERROR
  • Use IMAPISession.Logoff
  • Use MAPIUninitialize
and
How to use the HrOpenSessionObject function for retrieving a MAPI IMAPIProp interface for the current session object (user) and get all existing user properties.

Example01EM as Compiled Application

DELPHI 6 preview
Project(DELPHI 6) ZIP file

Source Code: In package
img Example # 2
Retrieve Microsoft Exchange GAL (Global Address List)

This example will show you how to get access to GAL (Global Address List)
The GAL is a single address list that contains all addresses defined at a Microsoft Exchange Server.

GAL was presented for the first time in Microsoft Mail postoffice - one of Microsoft's first attempts to provide to users an option allowing them to exchange messages and files not by simply using shared directories and files.

For Mail users, the GAL's main purpose is to provide a single list where users can find all the addresses they can send mail to.
Users do not need to know the location of the user to whom they want to send mail.
Global Address List is a MAPI address book container that holds recipient entries for an entire organization and is available to all e-mail users in that organization.

We will learn how to use the following interfaces:
IAddrBook - The IAddrBook interface supports access to the MAPI address book and includes operations such as displaying common dialog boxes, opening containers, messaging users, and distribution lists, and performing name resolution.

IABContainer - The IABContainer interface provides access to address book containers.
MAPI and client applications call the methods of IABContainer to perform name resolution and to create, copy, and delete recipients.

IMAPITable - The IMAPITable interface is used to provide a read-only view of a table.
IMAPITable is used by clients and service providers to manipulate the way a table appears.

We will study in more details the following memory management functions -
MAPIAllocateBuffer, MAPIAllocateMore, MAPIFreeBuffer, FreePRows.
These functions are used actively in all applications using MAPI.

We will study the way MAPI Hierarchy Table and MAPI Content Table are used.
We will focus our attention on the ENTRYID structure and how to work with binary MAPI objects, as well as how to work with MAPI Rows and Columns.

We will not forget the restrictions we can apply.

Include some steps from Example #1 and
How to
  • Open Address Book
  • Work with ENTRYID
  • Find Exchange GAL
  • Open Exchange GAL
  • Work with PropTagArray structture
  • Work with RowSet structture
  • Use IAddrBook
  • Use IABContainer
  • Use IMAPITable
  • Work with Restriction structure
  • Work with PropValue structure
  • Work with MAPI Hierarchy Table
  • Work with MAPI Content Table
  • Use MAPI Table Columns
  • Query  MAPI Rows
  • etc...

Example02EM as Compiled Application


Source Code: In package
img Example # 3
Retrieve Microsoft Exchange "Light" Hierarchy (by Global Address List)

In the previous example we illustrated how to connect to Microsoft Exchange Server, how to obtain the GAL content and to display basic properties of the e-mail user such as PR_DISPLAY_NAME and PR_EMAIL_ADDRESS.

In the current example we will review the Hierarchy tables. Through them we may build a tree that displays Exchange Organization (5.5).

A hierarchy table contains information about the containers in an address book container.
Each row of a hierarchy table contains a set of columns with information about address book container.
Hierarchy tables are implemented by address book providers to show a tree of containers within the address book.
Containers that cannot hold subcontainers, as indicated by the absence of the AB_SUBCONTAINERS flag in their PR_CONTAINER_FLAGS property, do not implement a hierarchy table.

We will also learn how we can turn the PSBinary data in a more user-friendly data type, such as String (for visualization).
We will not take time to explain the usage of functions and data that were discussed in the previous examples.
This example requires connection to Microsoft Exchange Server for efficient implementation.

How to
  • Use "light" version for MapiInitialize
  • Open Address Book
  • Get Hierarchy Table
  • Use PARENT ENTRYID
  • Set  MAPI  Columns
  • Get Row Count
  • Query MAPI Rows
  • Build Tree
  • Get included (default) Property list for a MAPI Object
  • Convert MAPI Binary Value (i.e. ENTRYID) To String
  • ...

Example03EM as Compiled Application


Source Code: In package
  continue...
  The Next Extended MAPI in Delphi Examples
Copyright © 2021 IMIBO
Privacy Statement