 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Oliver Giesen Guest
|
Posted: Wed Sep 15, 2004 8:12 am Post subject: OOM to Extended MAPI woes. |
|
|
I'm trying to retrieve the IMAPIFolder interface from a MAPIFolder
reference I got via OOM. AFAICT from the various examples I've found so
far, the following should work:
function ExtFolderFromOOMFolder(const AOOMFolder: MAPIFolder;
const ASession: IMAPISession; out AExtFolder: IUnknown): HRESULT;
var
lFolderId: String;
lItemType: Cardinal;
begin
lFolderId := HexToBinStr(AFolder.EntryID);
Result := ASession.OpenEntry(Length(lFolderId),
PENTRYID(PChar(lFolderId)),
IMAPIFolder,
MAPI_BEST_ACCESS,
lItemType,
AExtFolder);
end;
Unfortunately it never does. It always just returns E_FAIL. :(
I'm trying this with Outlook 2000 against an Exchange 2000 server
(that's why I'm not just using the MAPIOBJECT property in case you
wondered).
HexToBinStr is a utility function that Dmitry once posted for
converting the hex string representation into a char array. This works
alright in other instances.
I have no problem opening the folder via the EntryID obtained from the
MAPIFolder using OutlookSpy...
Any hints or ideas?
Oliver
|
|
| Back to top |
|
 |
Leonid Zeitlin Guest
|
Posted: Wed Sep 15, 2004 11:30 am Post subject: Re: OOM to Extended MAPI woes. |
|
|
Oliver,
Did you call MAPIInitialize before that? You need to call it before any
other MAPI calls.
Regards,
Leonid
"Oliver Giesen" <NO.ogware.SPAM (AT) gmx (DOT) ALLOWED.net.INVALID> ???????/???????? ?
???????? ?????????: news:4147f962$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I'm trying to retrieve the IMAPIFolder interface from a MAPIFolder
reference I got via OOM. AFAICT from the various examples I've found so
far, the following should work:
function ExtFolderFromOOMFolder(const AOOMFolder: MAPIFolder;
const ASession: IMAPISession; out AExtFolder: IUnknown): HRESULT;
var
lFolderId: String;
lItemType: Cardinal;
begin
lFolderId := HexToBinStr(AFolder.EntryID);
Result := ASession.OpenEntry(Length(lFolderId),
PENTRYID(PChar(lFolderId)),
IMAPIFolder,
MAPI_BEST_ACCESS,
lItemType,
AExtFolder);
end;
Unfortunately it never does. It always just returns E_FAIL. :(
I'm trying this with Outlook 2000 against an Exchange 2000 server
(that's why I'm not just using the MAPIOBJECT property in case you
wondered).
HexToBinStr is a utility function that Dmitry once posted for
converting the hex string representation into a char array. This works
alright in other instances.
I have no problem opening the folder via the EntryID obtained from the
MAPIFolder using OutlookSpy...
Any hints or ideas?
Oliver
|
|
|
| Back to top |
|
 |
Oliver Giesen Guest
|
Posted: Wed Sep 15, 2004 11:38 am Post subject: Re: OOM to Extended MAPI woes. |
|
|
Leonid Zeitlin wrote:
| Quote: | Did you call MAPIInitialize before that? You need to call it before
any other MAPI calls.
|
Yes, I did call it.
In fact, even though I still don't know why this doesn't work, the
problem has by now solved itself for me. What I was effectively trying
to do was read an extended MAPI property (PR_ADDRESS_BOOK_ENTRYID) of
the folder using Redemption's MAPIUtil.HrGetOneProp method.
I had simply missed that I could simply pass the MAPIFolder reference
directly to that method, I didn't need the IMAPIFolder reference at all
in order to accomplish this.
Still curious why this failed, though...
Cheers and thanks for your time,
Oliver
|
|
| Back to top |
|
 |
Dmitry Streblechenko Guest
|
Posted: Wed Sep 15, 2004 5:47 pm Post subject: Re: OOM to Extended MAPI woes. |
|
|
Where does the folder come from? Note that if you have never opened the
folder's parent message store in that session, open entry can and will fail.
This is especially true for the objects from non-default stores.
Try to open the parent store first (IMAPISession.OpenMsgStore), then open
the folder through the store (IMsgStore.OpenEntry rather than
IMAPISession.OpenEntry)
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Oliver Giesen" <NO.ogware.SPAM (AT) gmx (DOT) ALLOWED.net.INVALID> wrote
| Quote: | I'm trying to retrieve the IMAPIFolder interface from a MAPIFolder
reference I got via OOM. AFAICT from the various examples I've found so
far, the following should work:
function ExtFolderFromOOMFolder(const AOOMFolder: MAPIFolder;
const ASession: IMAPISession; out AExtFolder: IUnknown): HRESULT;
var
lFolderId: String;
lItemType: Cardinal;
begin
lFolderId := HexToBinStr(AFolder.EntryID);
Result := ASession.OpenEntry(Length(lFolderId),
PENTRYID(PChar(lFolderId)),
IMAPIFolder,
MAPI_BEST_ACCESS,
lItemType,
AExtFolder);
end;
Unfortunately it never does. It always just returns E_FAIL. :(
I'm trying this with Outlook 2000 against an Exchange 2000 server
(that's why I'm not just using the MAPIOBJECT property in case you
wondered).
HexToBinStr is a utility function that Dmitry once posted for
converting the hex string representation into a char array. This works
alright in other instances.
I have no problem opening the folder via the EntryID obtained from the
MAPIFolder using OutlookSpy...
Any hints or ideas?
Oliver
|
|
|
| Back to top |
|
 |
Oliver Giesen Guest
|
Posted: Thu Sep 16, 2004 7:49 am Post subject: Re: OOM to Extended MAPI woes. |
|
|
Dmitry Streblechenko wrote:
| Quote: | Where does the folder come from?
|
Application.ActiveExplorer.CurrentFolder
In this case, it was a public folder on an Exchange server.
| Quote: | Note that if you have never opened
the folder's parent message store in that session, open entry can and
will fail. This is especially true for the objects from non-default
stores. Try to open the parent store first
(IMAPISession.OpenMsgStore),
|
This does indeed already happen immediately before the code piece that
was causing the error (I'm checking for the mailbox owner).
| Quote: | then open the folder through the store
(IMsgStore.OpenEntry rather than IMAPISession.OpenEntry)
|
Thanks, I will keep that in mind when I next stumble across something
similar.
Cheers,
Oliver
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|