A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

C# Error when calling MAPI.Session.Logon()



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 17th 08, 02:26 PM posted to microsoft.public.outlook.program_addins
Johan Machielse
external usenet poster
 
Posts: 1
Default C# Error when calling MAPI.Session.Logon()

Dear reader,

See next piece of code (written in C#):

MAPI.Session mapiSession = new MAPI.Session();
mapiSession.Logon(null, null, false, false, 0, false, "");

The call mapiSession.Logon() throws the following exception:
[Collaboration Data Objects - [E_INVALIDARG(80070057)]

What can I do to solve this problem; which arguments do I have to pass?

Thank you in advance,

Johan Machielse
Avanade


Ads
  #2  
Old July 17th 08, 06:30 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default C# Error when calling MAPI.Session.Logon()

First of all CDO 1.21 is not supported for use with any managed code, so if
it doesn't work then you won't get any help.

That said, you could try using null strings instead of null for the first 2
arguments to Logon().

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Johan Machielse" Johan wrote in
message ...
Dear reader,

See next piece of code (written in C#):

MAPI.Session mapiSession = new MAPI.Session();
mapiSession.Logon(null, null, false, false, 0, false, "");

The call mapiSession.Logon() throws the following exception:
[Collaboration Data Objects - [E_INVALIDARG(80070057)]

What can I do to solve this problem; which arguments do I have to pass?

Thank you in advance,

Johan Machielse
Avanade



  #3  
Old July 17th 08, 08:00 PM posted to microsoft.public.outlook.program_addins
Johan Machielse[_2_]
external usenet poster
 
Posts: 11
Default C# Error when calling MAPI.Session.Logon()

Ken,

thank you for your quick answer, but now if you want to create an add-in for
Outlook 2003/2007 which changes the color labels of the appointments in a
calendar, what is than the best way to solve this (I want to use .NET to
create the plug-in, but CDO 1.21 is not supported...)?

Thank you in advance,

Johan Machielse
Avanade



"Ken Slovak - [MVP - Outlook]" wrote:

First of all CDO 1.21 is not supported for use with any managed code, so if
it doesn't work then you won't get any help.

That said, you could try using null strings instead of null for the first 2
arguments to Logon().

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Johan Machielse" Johan wrote in
message ...
Dear reader,

See next piece of code (written in C#):

MAPI.Session mapiSession = new MAPI.Session();
mapiSession.Logon(null, null, false, false, 0, false, "");

The call mapiSession.Logon() throws the following exception:
[Collaboration Data Objects - [E_INVALIDARG(80070057)]

What can I do to solve this problem; which arguments do I have to pass?

Thank you in advance,

Johan Machielse
Avanade




  #4  
Old July 18th 08, 01:11 AM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default C# Error when calling MAPI.Session.Logon()

Or, better yet, set Session.MAPIOBJECT property to Namespace.MAPIOBJECT from
OOM to make sure CDO 1.21 and Outlook share the same MAPI session.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Ken Slovak - [MVP - Outlook]" wrote in message
...
First of all CDO 1.21 is not supported for use with any managed code, so
if it doesn't work then you won't get any help.

That said, you could try using null strings instead of null for the first
2 arguments to Logon().

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Johan Machielse" Johan wrote in
message ...
Dear reader,

See next piece of code (written in C#):

MAPI.Session mapiSession = new MAPI.Session();
mapiSession.Logon(null, null, false, false, 0, false, "");

The call mapiSession.Logon() throws the following exception:
[Collaboration Data Objects - [E_INVALIDARG(80070057)]

What can I do to solve this problem; which arguments do I have to pass?

Thank you in advance,

Johan Machielse
Avanade





  #5  
Old July 18th 08, 01:13 AM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default C# Error when calling MAPI.Session.Logon()

Outlook 2007 exposes AppointmentItem.PropertyAccessor object that lets you
set MAPI properties.
In the older versions of Outlook you will need to use Extended MAPI or CDO
1.21 (neither is supported in .Net) or plug Redemption (url below) /plug

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Johan Machielse" wrote in
message ...
Ken,

thank you for your quick answer, but now if you want to create an add-in
for
Outlook 2003/2007 which changes the color labels of the appointments in a
calendar, what is than the best way to solve this (I want to use .NET to
create the plug-in, but CDO 1.21 is not supported...)?

Thank you in advance,

Johan Machielse
Avanade



"Ken Slovak - [MVP - Outlook]" wrote:

First of all CDO 1.21 is not supported for use with any managed code, so
if
it doesn't work then you won't get any help.

That said, you could try using null strings instead of null for the first
2
arguments to Logon().

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Johan Machielse" Johan wrote in
message ...
Dear reader,

See next piece of code (written in C#):

MAPI.Session mapiSession = new MAPI.Session();
mapiSession.Logon(null, null, false, false, 0, false, "");

The call mapiSession.Logon() throws the following exception:
[Collaboration Data Objects - [E_INVALIDARG(80070057)]

What can I do to solve this problem; which arguments do I have to pass?

Thank you in advance,

Johan Machielse
Avanade






  #6  
Old July 18th 08, 10:40 AM posted to microsoft.public.outlook.program_addins
Johan Machielse[_2_]
external usenet poster
 
Posts: 11
Default C# Error when calling MAPI.Session.Logon()

Hi Ken,

I figured out what how the Logon method has to be called:

mapiSession.Logon("Default Outlook Profile",
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value);
It works!

Regards,

Johan Machielse
Avanade

"Ken Slovak - [MVP - Outlook]" wrote:

First of all CDO 1.21 is not supported for use with any managed code, so if
it doesn't work then you won't get any help.

That said, you could try using null strings instead of null for the first 2
arguments to Logon().

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Johan Machielse" Johan wrote in
message ...
Dear reader,

See next piece of code (written in C#):

MAPI.Session mapiSession = new MAPI.Session();
mapiSession.Logon(null, null, false, false, 0, false, "");

The call mapiSession.Logon() throws the following exception:
[Collaboration Data Objects - [E_INVALIDARG(80070057)]

What can I do to solve this problem; which arguments do I have to pass?

Thank you in advance,

Johan Machielse
Avanade




  #7  
Old July 18th 08, 01:57 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default C# Error when calling MAPI.Session.Logon()

You seem to have it solved now, but for things like that I use the
Redemption library that Dmitry mentioned in his post. It does everything CDO
did and a whole lot more.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Johan Machielse" wrote in
message ...
Ken,

thank you for your quick answer, but now if you want to create an add-in
for
Outlook 2003/2007 which changes the color labels of the appointments in a
calendar, what is than the best way to solve this (I want to use .NET to
create the plug-in, but CDO 1.21 is not supported...)?

Thank you in advance,

Johan Machielse
Avanade


  #8  
Old July 18th 08, 06:28 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default C# Error when calling MAPI.Session.Logon()

That will break if the user has more than one profile and a non-default
profiel is used.
Setting the MAPIOBJECT property (Outlook 2002 and up) will work much better.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Johan Machielse" wrote in
message ...
Hi Ken,

I figured out what how the Logon method has to be called:

mapiSession.Logon("Default Outlook Profile",
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value);
It works!

Regards,

Johan Machielse
Avanade

"Ken Slovak - [MVP - Outlook]" wrote:

First of all CDO 1.21 is not supported for use with any managed code, so
if
it doesn't work then you won't get any help.

That said, you could try using null strings instead of null for the first
2
arguments to Logon().

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Johan Machielse" Johan wrote in
message ...
Dear reader,

See next piece of code (written in C#):

MAPI.Session mapiSession = new MAPI.Session();
mapiSession.Logon(null, null, false, false, 0, false, "");

The call mapiSession.Logon() throws the following exception:
[Collaboration Data Objects - [E_INVALIDARG(80070057)]

What can I do to solve this problem; which arguments do I have to pass?

Thank you in advance,

Johan Machielse
Avanade






 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MAPI Session Logon error AVIS Outlook and VBA 17 April 29th 08 01:12 PM
Create MAPI Session failure derek mang Outlook and VBA 3 April 24th 08 02:27 PM
CDO Outlook security prompt hangs, vb script Mapi Session [email protected] Outlook and VBA 2 April 17th 08 11:03 AM
OLK2007 : The Oper Failed : Application.CreateObject("MAPI.Session Bill Billmire Outlook - Using Forms 3 January 7th 07 01:02 AM
Error creating an MAPI session Dominique Schroeder Outlook - Using Forms 1 March 7th 06 02:25 PM


All times are GMT +1. The time now is 08:34 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.