Outlook OM : Method Restrict() has problems with parentheses

T

tsfreaks

I'm trying to filter for a specific name using;
olItems.Restrict("[From] = John Doe()");

Notice the parentheses in the string. If the string
contains parentheses in it, I get the following exception.

An unhandled exception of
type 'System.Runtime.InteropServices.COMException'
occurred in ioemail.dll
Additional information: Condition is not valid.

How do I get Restrict to work with parentheses?
 
T

tsfreaks

This won't work. No need to add additional "" to a string.
Thanks,
Alex
-----Original Message-----
Use quotes:
olItems.Restrict("[From] = "John Doe()"");

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


I'm trying to filter for a specific name using;
olItems.Restrict("[From] = John Doe()");

Notice the parentheses in the string. If the string
contains parentheses in it, I get the following exception.

An unhandled exception of
type 'System.Runtime.InteropServices.COMException'
occurred in ioemail.dll
Additional information: Condition is not valid.

How do I get Restrict to work with parentheses?


.
 
D

Dmitry Streblechenko

The following codse works just fine for me:

set Items = MAPIFolder.Items.Restrict("[Subject] = ""test subject()""")
MsgBox Items.Count

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


tsfreaks said:
This won't work. No need to add additional "" to a string.
Thanks,
Alex
-----Original Message-----
Use quotes:
olItems.Restrict("[From] = "John Doe()"");

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


I'm trying to filter for a specific name using;
olItems.Restrict("[From] = John Doe()");

Notice the parentheses in the string. If the string
contains parentheses in it, I get the following exception.

An unhandled exception of
type 'System.Runtime.InteropServices.COMException'
occurred in ioemail.dll
Additional information: Condition is not valid.

How do I get Restrict to work with parentheses?


.
 
T

tsfreaks

ahhh.. ok. I got it to work. Instead of double quotes, I
tried using single quotes and it worked. Thank you for
helping me with this.

olItems.Restrict("[From] = 'John Doe()'");

and just to test something "'"Hello World"'". I want to
see how this site handles quotes.

-----Original Message-----
The following codse works just fine for me:

set Items = MAPIFolder.Items.Restrict("[Subject] = ""test subject()""")
MsgBox Items.Count

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


This won't work. No need to add additional "" to a string.
Thanks,
Alex
-----Original Message-----
Use quotes:
olItems.Restrict("[From] = "John Doe()"");

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


I'm trying to filter for a specific name using;
olItems.Restrict("[From] = John Doe()");

Notice the parentheses in the string. If the string
contains parentheses in it, I get the following exception.

An unhandled exception of
type 'System.Runtime.InteropServices.COMException'
occurred in ioemail.dll
Additional information: Condition is not valid.

How do I get Restrict to work with parentheses?



.


.
 

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