Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Handling Outlook COM exceptions in .Net

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Handling Outlook COM exceptions in .Net
blueturtle[ at ]walla.co.il 23.02.2006 12:45:47
Hi,

I has anybody encountered the following behaviour:
COM exception thrown from Outlook, when handled in .Net,
has different HRESULT every time, for the same error..

E.g.
I cause an exception by using a wrong filter in restrict (adding ZZZ)


Outlook.Items inboxItemsCollection;
inboxItemsCollection.Restrict("[ReceivedTimeZZZ >= '#2/23/2006
14:18#'")

I get exception:
"The property "ReceivedTimeZZZ" is unknown."

The value in class System.Runtime.InteropServices.COMException
of ErrorCode is -1317928951

and in another call it will be
ErrorCode -1005453303

on every call (exception), ErrorCode will get a different value.


Is this a known problem ? in Outlook ? Interop ?
It occurs on various methods, not just Restrict.

It is also discussed here:
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_frm/thread/81cb43297132c25/bca91332ac0e89f3?tvc=1&q=COMException+errorcode+hresult+outlook&hl=en#bca91332ac0e89f3


Thanks for any help.
Si.

Re: Handling Outlook COM exceptions in .Net
"Sue Mosher [MVP-Outlook]" <suemvp[ at ]outlookcode.com> 23.02.2006 13:26:41
You may be running up against any or all of these three issues with Restrict:

1) You can use Find and Restrict with custom fields only if those fields have been defined in the folder, not just in individual items. A good test is whether a folder view can show the data in those fields from the User-defined Fields in Folder list of fields.

2) The proper syntax for the field name is to enclose it in square brackets; you have only an open bracket, not a closing bracket.

3) The date element must be enclosed in text quotes, not date quotes and definitely not both kinds of quotes, which is how you have it.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


<blueturtle[ at ]walla.co.il> wrote in message news:1140698747.342734.205420[ at ]i40g2000cwc.googlegroups.com...
[Quoted Text]
> Hi,
>
> I has anybody encountered the following behaviour:
> COM exception thrown from Outlook, when handled in .Net,
> has different HRESULT every time, for the same error..
>
> E.g.
> I cause an exception by using a wrong filter in restrict (adding ZZZ)
>
>
> Outlook.Items inboxItemsCollection;
> inboxItemsCollection.Restrict("[ReceivedTimeZZZ >= '#2/23/2006
> 14:18#'")
>
> I get exception:
> "The property "ReceivedTimeZZZ" is unknown."
>
> The value in class System.Runtime.InteropServices.COMException
> of ErrorCode is -1317928951
>
> and in another call it will be
> ErrorCode -1005453303
>
> on every call (exception), ErrorCode will get a different value.
>
>
> Is this a known problem ? in Outlook ? Interop ?
> It occurs on various methods, not just Restrict.
>
> It is also discussed here:
> http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_frm/thread/81cb43297132c25/bca91332ac0e89f3?tvc=1&q=COMException+errorcode+hresult+outlook&hl=en#bca91332ac0e89f3
>
>
> Thanks for any help.
> Si.
>
Re: Handling Outlook COM exceptions in .Net
blueturtle[ at ]walla.co.il 23.02.2006 14:59:45
Hi,
Thanks for your reply.

Using "Restrict" was just a sample how to cause an exception.
It can be seen also on "Outlook.Recipient.FreeBusy" and
"Attachments.Add".
The issue is that in COM, the practice is to compare the HRESULT value
against a list of known numeric values (or test certain bits)
but here, the numeric value seem to be random, and only the description
is the same (at least it's prolog).

As for your comments, this syntax of the filter seems to work fine so
far.
The date element was enclosed with "#", to avoid any ambiguity as
whether 7/4 is July's 4th, or April's 7th.
I didn't find any documentation about the compatibility of the syntax
among OS with different cultures used, so I used this one, which seems
to work.

Itzik.

Re: Handling Outlook COM exceptions in .Net
"Josh Einstein" <josheinstein[ at ]hotmail.com> 24.02.2006 06:53:56
I've run into this too and in some exceptions I don't even get a
description.

--
Josh Einstein
Einstein Technologies
Microsoft Tablet PC MVP
Tablet Enhancements for Outlook 2.0 - Try it free for 14 days
www.tabletoutlook.com


<blueturtle[ at ]walla.co.il> wrote in message
news:1140706785.425681.28450[ at ]g14g2000cwa.googlegroups.com...
[Quoted Text]
> Hi,
> Thanks for your reply.
>
> Using "Restrict" was just a sample how to cause an exception.
> It can be seen also on "Outlook.Recipient.FreeBusy" and
> "Attachments.Add".
> The issue is that in COM, the practice is to compare the HRESULT value
> against a list of known numeric values (or test certain bits)
> but here, the numeric value seem to be random, and only the description
> is the same (at least it's prolog).
>
> As for your comments, this syntax of the filter seems to work fine so
> far.
> The date element was enclosed with "#", to avoid any ambiguity as
> whether 7/4 is July's 4th, or April's 7th.
> I didn't find any documentation about the compatibility of the syntax
> among OS with different cultures used, so I used this one, which seems
> to work.
>
> Itzik.
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net