Extended MAPI in DELPHI
LazyMAPI
Included helper classes
TMAPIMailboxProxy
unit: MAPIMailboxProxy.pas
file path: ..\Library\Helpers\
version: 2026.11
uses Windows, Types, Controls, CommCtrl, ComCtrls, SysUtils, ExtendedMAPI, IMIEMTypes, MAPITable, MAPIFormViewer
Binds a mailbox to a TTreeView (folders) and a TListView (messages).
See LazyMAPI #8 for it at work.
Classes and interfaces
| TMAPIMailboxProxy | class(TObject) |
TMAPIMailboxProxy = class(TObject)
unit MAPIMailboxProxy.pas
| Kind | Declaration | Description |
| constructor | constructor Create(WindowHandle: HWND; const StoresTreeView: TTreeView; const MessagesListView: TListView; const MAPISession: IMAPISession); |
A mailbox browser over a tree view (stores and folders) and a virtual list view (the messages of the selected folder) for a MAPI session; forms are shown with WindowHandle as parent. The calendar view starts with this month and covers 2 months. |
| destructor | destructor Destroy; override; |
Clears the tree and the list, frees the message table, image lists and form manager. |
| procedure | procedure ReloadIcons; |
Loads the folder and message icons again in the size of the current DPI of the views and the colours of the current VCL style (MAPIIconStrips); call it after a style change or a DPI change of the form. |
| procedure | procedure BuildTree; |
Fills the tree view with the message stores of the session (their folders are added when a store node is expanded). Raises EMAPIError without a session or tree view. |
| procedure | procedure ClearTree; |
Removes all nodes of the tree view and frees their data. |
| procedure | procedure ShowMessage(const Modal: Boolean = False); |
Opens the selected message in its Outlook form (only when exactly one item is selected). |
| procedure | procedure OnTreeNodeExpanding(Node: TTreeNode); |
Adds the subfolders of the node being expanded. Connect it to the event of the same name of the control. |
| procedure | procedure OnTreeNodeCollapsing(Node: TTreeNode); |
Removes the subfolders of the node being collapsed. Connect it to the event of the same name of the control. |
| procedure | procedure OnTreeNodeChange(Node: TTreeNode); |
Opens the selected store or folder and lists the messages of a folder (columns by the folder kind; a calendar shows the occurrences of the calendar range). Connect it to the event of the same name of the control. |
| procedure | procedure FitColumns; |
Fits the columns of a mail folder to the width of the list: the From / To and Subject columns share what the icon, date and size columns and the vertical scroll bar leave (VCL’s AutoSize ignored the scroll bar and the Size column was partly hidden). Call it when the list changes its size. |
| procedure | procedure OnMsgLVColumnClick(Column: TListColumn); |
Sorts the messages by the clicked column; a second click reverses the order. Connect it to the event of the same name of the control. |
| procedure | procedure OnMsgLVData(Item: TListItem); |
Fills a list item of the virtual list view from its table row (the columns depend on the folder kind). Connect it to the event of the same name of the control. (OnData) |
| procedure | procedure SetCalendarDateRange(const StartDate: TDate; const MonthsRange: Byte); |
Sets the calendar range (start date and number of months) and lists the occurrences again. |
| property | property MAPIStore: IMsgStore read FMAPIStore; |
The store of the selected node. |
| property | property MAPIFolder: IMAPIFolder read FMAPIFolder; |
The selected folder; nil when a store node is selected. |
| property | property MAPIMsg: IMessage read GetMAPIMsg; |
The selected message (one item selected), opened read-only; in a calendar, an exception or a single occurrence of a recurring appointment is given as a virtual message. nil without a single selection. |
| property | property MAPITable: IMAPITable read GetMAPITable; |
The contents table shown in the list; nil when no folder is selected. |
| property | property MsgTable: TMAPITable read FMsgTable; |
The TMAPITable behind the list (owned by the proxy). |
| property | property FolderType: TMAPIFldType read FFolderType; |
The kind of the selected folder. |
| property | property TreeView: TTreeView read FTreeView; |
The tree view of stores and folders. |
| property | property ListView: TListView read FListView; |
The list view of messages. |
| property | property MonthsInCalendarView: Byte read FMonthsInCalendarView write SetMonthsInCalendarView; |
How many months of a calendar are listed (at least 1); setting it lists the occurrences again. |
| property | property CalendarStartDate: TDate read FCalendarStartDate write SetCalendarStartDate; |
The first day of the calendar range. |
| property | property IsVirtualTable: Boolean read FIsVirtualTable; |
True when the list shows a table built by the proxy (the occurrences of a calendar) instead of a folder contents table. |
| property | property IsVirtualMessage: Boolean read FIsVirtualMessage; |
True when MAPIMsg is a virtual message (an occurrence of a recurring appointment). |
| property | property OnLine: Boolean read FOnLine write FOnLine; |
True (the default): the stores are opened with MDB_ONLINE and the folders with MAPI_NO_CACHE, i.e. an Exchange mailbox is read from the server. False: the stores and folders are opened as the profile is (a cached mailbox from its local copy). Set it before BuildTree; a store open in the other mode is not reopened. |
