MessageStore Contents
This application demonstrates how to open a messagestore, how to get all the folders in the store, how to get all the items of a folder and how to open an item and read it's content.
Opening a folder:
..
var
MsgStore: IRwEWSMsgStore;
RootFolder: IRwEWSFolder;
begin
MsgStore := EWSSession.OpenDefaultMsgStore;
RootFolder := MsgStore.GetFolder(dfinroot);
..
Getting the contents of a folder:
..
var
SubFolders: IRwEWSFolders;
FolderNode: TTreeNode;
Caption: string;
begin
SubFolders := AFolder.GetSubFolders;
SubFolders.Fields.Add(FLD_FOLDER_FOLDERID);
SubFolders.Fields.Add(FLD_FOLDER_DISPLAYNAME);
SubFolders.Fields.Add(FLD_FOLDER_CHILDFOLDERCOUNT);
SubFolders.Fields.Add(FLD_FOLDER_TOTALCOUNT);
SubFolders.Fields.Add(FLD_FOLDER_DISTINGUISHEDFOLDERID);
SubFolders.First;
while not SubFolders.EOF do
begin
if SubFolders.FieldByName(FLD_FOLDER_TOTALCOUNT).AsInteger > 0 then
Caption := Format('%s (%d)',[SubFolders.FieldByName(FLD_FOLDER_DISPLAYNAME).AsString, SubFolders.FieldByName(FLD_FOLDER_TOTALCOUNT).AsInteger])
else
Caption := SubFolders.FieldByName(FLD_FOLDER_DISPLAYNAME).AsString;
FolderNode := tvMsgStores.Items.AddChild(AParentNode, Caption);
FolderNode.Data := TTreeNodeData.Create;
FolderNode.ImageIndex := GetFolderTypeImageIndex(SubFolders.FolderFieldType, SubFolders.FieldByName(FLD_FOLDER_DISTINGUISHEDFOLDERID).AsType);
FolderNode.SelectedIndex := FolderNode.ImageIndex;
FolderNode.HasChildren := SubFolders.FieldByName(FLD_FOLDER_CHILDFOLDERCOUNT).AsInteger > 0;
TTreeNodeData(FolderNode.Data).MsgStore := AMsgStore;
TTreeNodeData(FolderNode.Data).FolderId := SubFolders.FieldByName(FLD_FOLDER_FOLDERID).AsType;
SubFolders.Next;
end;
..
Screenshot: