Call MAPILogonEx() from COM Add-in?

E

Eric

The way I understand it, from reading various posts by MVP's in this
newsgroup, I need to call MAPILogonEx() to get an IMAPISession pointer
in Outlook 2000. In 2002 I can just use the
Application.Session.MAPIOBJECT property, but I need my code to work in
OL2K also.

I keep getting the error "Param Incorrect" when I try and invoke this
line of code in the OnConnect event of my add-in:

MAPILogonEx(NULL,NULL,NULL,MAPI_ALLOW_OTHERS,0,&MapiSession);

I've tried with and without the MAPI_ALLOW_OTHERS flags, and also
tried changing other various things, but can't get anything to work.
I don't have a default profile setup, I have Outlook set to prompt,
could this be a problem since I'm not passing MAPI_LOGON_UI? I don't
want to display a login prompt, and I want to make sure I'm using the
same profile (and session) as Outlook.

Do I need to call MAPIInitialize() first? The way I understand it, I
shouldn't have to, since I'm running on the main thread.
 
E

Eric

Thanks for the help again, this time it was just some misleading
documentation. In the MAPI.HLP file that was installed with Borland
Builder 6, though written by Microsoft, dated February 01, 2002, it
had MAPILogonEx() declared with 6 paramaters, instead of the 5 that it
actually has:

ULONG MAPILogonEx(ULONG ulUIParam, LPTSTR lpszProfileName, LPTSTR
lpszPassword, FLAGS flFlags, ULONG ulReserved, LPLHANDLE lplhSession)

Once I removed the "ulReserved" param from the decleration, everything
worked fine.

Hopefully no one else will make this mistake, but if they do maybe
they'll find this post and figure out the problem. The compiler
didn't complain because I'm using dynamicly loaded functions with
GetProcAddress().
 
D

Dmitry Streblechenko

Don't use the Win API help files installed by Delphi - they are terribly
outdated. MSDN is much better.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top