Request # 25
How to Open another person’s Calendar folder and post/create an Appointment item?
This example requires you to use a Microsoft Exchange account.
The ability to open another person’s folder, and whether or not you can change it, is controlled by the owner of the folder.
Code snip:
function TfrmMain.GetAnotherUserMdb(ServerDN, MailboxDN: AnsiString): IMsgStore;
var
XManageStore: IExchangeManageStore;
EntryID: TSBinary;
begin
Result := nil;
ZeroMemory(@EntryID, SizeOf(TSBinary));
hr := MyMsgStore.QueryInterface(IID_IExchangeManageStore, XManageStore);
If failed(hr) Or Not Assigned(XManageStore) Then
raise EMAPIError.CreateMAPI(MyMsgStore, hr);
hr := XManageStore.CreateStoreEntryID(PAnsiChar(ServerDN),
PAnsiChar(MailboxDN),
OPENSTORE_USE_ADMIN_PRIVILEGE Or OPENSTORE_TAKE_OWNERSHIP,
EntryID.cb,
PENTRYID(EntryID.lpb));
If failed(hr) Then
raise EMAPIError.CreateMAPI(nil, hr);
try
hr := MAPISession.OpenMsgStore(0,
EntryID.cb,
PENTRYID(EntryID.lpb),
@IID_IMsgStore,
MDB_NO_MAIL Or // MDB_NO_DIALOG or
MDB_TEMPORARY Or // message store not added to MAPI profile
MAPI_BEST_ACCESS, // normally WRITE, but allow access to RO store
Result);
If failed(hr) Then
raise EMAPIError.CreateMAPI(MAPISession, hr);
finally
If Assigned(EntryID.lpb) Then
MAPIFreeBuffer(EntryID.lpb);
end;
end;
Download Request #25 as Compiled Application
Download Project (DELPHI 10.4) ZIP file
Source Code: In package


