Mapi function error code

  • Thread starter Thread starter Groghz
  • Start date Start date
G

Groghz

Hi,

I'm pinvoking a mapi function in c#

[DllImport("cemapi.dll", SetLastError = true)]
public static extern int MailSwitchToAccount(string pszAccount,
UInt32 dwFlags);

I then call the function :

if (Mapi.MailSwitchToAccount("My_account",
Mapi.MCF_ACCOUNT_IS_NAME | Mapi.MCF_RUN_IN_BACKGROUND) != 0)
{
int err = Marshal.GetLastWin32Error();
Win32Exception ex = new Win32Exception(err);
Log("mapi", Severity.Error, "MailSwitchToAccount()
failed with win32error=" + ex.NativeErrorCode + ", ex.Message=" +
ex.Message);
}

The problem is MailSwitchToAccount never returns 0, and so a the error
handling code is executed. In the logs, the ex.NativeErrorCode is
always 0, which doesn't seem to be a valid error code.

Is there another way to find the error code ?

regards,

manu
 
Since MailSwitchToAccount is a WM5.0 API, and you are using managed code,
why not use the managed equivalent in the WM5.0 SDK -
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.SwitchToAccount

With regards your query, if you want to know what the error code is you need
to look at the integer return value from MailSwitchToAccount.

Peter
 
I didn't know this dll ;)

I'll give it a try !

Thanks !

Peter Foot [MVP] a écrit :
Since MailSwitchToAccount is a WM5.0 API, and you are using managed code,
why not use the managed equivalent in the WM5.0 SDK -
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.SwitchToAccount

With regards your query, if you want to know what the error code is you need
to look at the integer return value from MailSwitchToAccount.

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com

Hi,

I'm pinvoking a mapi function in c#

[DllImport("cemapi.dll", SetLastError = true)]
public static extern int MailSwitchToAccount(string pszAccount,
UInt32 dwFlags);

I then call the function :

if (Mapi.MailSwitchToAccount("My_account",
Mapi.MCF_ACCOUNT_IS_NAME | Mapi.MCF_RUN_IN_BACKGROUND) != 0)
{
int err = Marshal.GetLastWin32Error();
Win32Exception ex = new Win32Exception(err);
Log("mapi", Severity.Error, "MailSwitchToAccount()
failed with win32error=" + ex.NativeErrorCode + ", ex.Message=" +
ex.Message);
}

The problem is MailSwitchToAccount never returns 0, and so a the error
handling code is executed. In the logs, the ex.NativeErrorCode is
always 0, which doesn't seem to be a valid error code.

Is there another way to find the error code ?

regards,

manu
 
The
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.SwitchToAccount
works fine.

But the switching is done in foreground : PocketOutlook opens and
switch the account. It's disturbing for the user.

Could the switching be done in background ?

regards,

manu


(e-mail address removed) a écrit :
I didn't know this dll ;)

I'll give it a try !

Thanks !

Peter Foot [MVP] a écrit :
Since MailSwitchToAccount is a WM5.0 API, and you are using managed code,
why not use the managed equivalent in the WM5.0 SDK -
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.SwitchToAccount

With regards your query, if you want to know what the error code is youneed
to look at the integer return value from MailSwitchToAccount.

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com

Hi,

I'm pinvoking a mapi function in c#

[DllImport("cemapi.dll", SetLastError = true)]
public static extern int MailSwitchToAccount(string pszAccount,
UInt32 dwFlags);

I then call the function :

if (Mapi.MailSwitchToAccount("My_account",
Mapi.MCF_ACCOUNT_IS_NAME | Mapi.MCF_RUN_IN_BACKGROUND) != 0)
{
int err = Marshal.GetLastWin32Error();
Win32Exception ex = new Win32Exception(err);
Log("mapi", Severity.Error, "MailSwitchToAccount()
failed with win32error=" + ex.NativeErrorCode + ", ex.Message=" +
ex.Message);
}

The problem is MailSwitchToAccount never returns 0, and so a the error
handling code is executed. In the logs, the ex.NativeErrorCode is
always 0, which doesn't seem to be a valid error code.

Is there another way to find the error code ?

regards,

manu
 
No it can't be done in bg

(e-mail address removed) a écrit :
The
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.SwitchToAccount
works fine.

But the switching is done in foreground : PocketOutlook opens and
switch the account. It's disturbing for the user.

Could the switching be done in background ?

regards,

manu


(e-mail address removed) a écrit :
I didn't know this dll ;)

I'll give it a try !

Thanks !

Peter Foot [MVP] a écrit :
Since MailSwitchToAccount is a WM5.0 API, and you are using managed code,
why not use the managed equivalent in the WM5.0 SDK -
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.SwitchToAccount

With regards your query, if you want to know what the error code is you need
to look at the integer return value from MailSwitchToAccount.

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com

Hi,

I'm pinvoking a mapi function in c#

[DllImport("cemapi.dll", SetLastError = true)]
public static extern int MailSwitchToAccount(string pszAccount,
UInt32 dwFlags);

I then call the function :

if (Mapi.MailSwitchToAccount("My_account",
Mapi.MCF_ACCOUNT_IS_NAME | Mapi.MCF_RUN_IN_BACKGROUND) != 0)
{
int err = Marshal.GetLastWin32Error();
Win32Exception ex = new Win32Exception(err);
Log("mapi", Severity.Error, "MailSwitchToAccount()
failed with win32error=" + ex.NativeErrorCode + ", ex.Message="+
ex.Message);
}

The problem is MailSwitchToAccount never returns 0, and so a the error
handling code is executed. In the logs, the ex.NativeErrorCode is
always 0, which doesn't seem to be a valid error code.

Is there another way to find the error code ?

regards,

manu
 
Back
Top