PC Review


Reply
Thread Tools Rate Thread

Call MAPILogonEx() from COM Add-in?

 
 
Eric
Guest
Posts: n/a
 
      16th Oct 2003
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.
 
Reply With Quote
 
 
 
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      16th Oct 2003
Try
MAPI_ALLOW_OTHERS | MAPI_USE_DEFAULT | MAPI_EXTENDED

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


"Eric" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.



 
Reply With Quote
 
Eric
Guest
Posts: n/a
 
      17th Oct 2003
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().


"Dmitry Streblechenko" <(E-Mail Removed)> wrote in message news:<O$(E-Mail Removed)>...
> Try
> MAPI_ALLOW_OTHERS | MAPI_USE_DEFAULT | MAPI_EXTENDED
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
>
> "Eric" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > MAPILogonEx(NULL,NULL,NULL,MAPI_ALLOW_OTHERS,0,&MapiSession);

 
Reply With Quote
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      17th Oct 2003
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


"Eric" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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().
>
>
> "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message

news:<O$(E-Mail Removed)>...
> > Try
> > MAPI_ALLOW_OTHERS | MAPI_USE_DEFAULT | MAPI_EXTENDED
> >
> > Dmitry Streblechenko (MVP)
> > http://www.dimastr.com/
> > OutlookSpy - Outlook, CDO
> > and MAPI Developer Tool
> >
> >
> > "Eric" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > MAPILogonEx(NULL,NULL,NULL,MAPI_ALLOW_OTHERS,0,&MapiSession);



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MAPILogonEx MON205 Microsoft Outlook Program Addins 6 20th Jul 2008 05:11 PM
Redemption+CBuilder: RDOSession.Logon MAPILogonEx-Error tsahling@hausmannwynen.de Microsoft Outlook Program Addins 2 1st Sep 2006 08:32 AM
Warning 1684 CA2214 : Microsoft.Usage : 'RandomShade..ctor(Int32, Int32, Int32, Int32, Int32)' contains a call chain that results in a call to a virtual method defined by the class. Review the following call stack for unintended consequences: steve bull Microsoft C# .NET 4 7th Jul 2005 05:54 PM
Are we new users supposed to call this number? I have auto dial on my XP in the dialer but am I required to call? Windows XP New Users 12 26th May 2005 03:47 PM
Memory leak in MAPIInitialize and MAPILogonEx. Mike M. Microsoft Outlook Program Addins 0 18th May 2004 01:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:05 PM.