ExchangeWebServices FindItem Restrictions
I think I'm starting to get a handle on the use of restrictions in FindItem, but I can't figure out one thing:
Say I want to search a folder for all mail items with a subject of "Hello" or "Goodbye" that haven't been read. I can easily search for mail items that haven't been read and have a subject line of "Hello" by using something like this (forgive the naming
conventions, code is borrowed):
'restrict the returned items to just items of a specific message class
Dim MsgClassField As PathToUnindexedFieldType = New PathToUnindexedFieldType()
MsgClassField.FieldURI = UnindexedFieldURIType.itemItemClass
Dim MsgClassToGet As ConstantValueType = New ConstantValueType()
MsgClassToGet.Value = "IPM.NOTE"
Dim MsgClassConstant As FieldURIOrConstantType = New FieldURIOrConstantType()
MsgClassConstant.Item = MsgClassToGet
Dim iett As IsEqualToType = New IsEqualToType()
iett.FieldURIOrConstant = MsgClassConstant
iett.Item = MsgClassField
'restrict the returned items to having a subject line "Hello"
Dim SubjectField As PathToUnindexedFieldType = New PathToUnindexedFieldType()
SubjectField.FieldURI = UnindexedFieldURIType.itemDateTimeReceived
Dim SubjectFieldToGet As ConstantValueType = New ConstantValueType()
SubjectFieldToGet.Value = "Hello"
Dim SubjectFieldConstant As FieldURIOrConstantType = New FieldURIOrConstantType()
StartDateReceivedConstant.Item = StartDateReceivedToGet
Dim ist As IsEqualToType = New IsEqualToType()
ist.FieldURIOrConstant = StartDateReceivedConstant
ist.Item = StartDateReceivedField
Dim at As AndType = New AndType()
ReDim at.Items(2)
at.Items(0) = iett
at.Items(1) = ist
Dim rt As RestrictionType = New RestrictionType()
rt.Item = at
Maybe I'm missing something, but it seems like I'd need an AndType AND an OrType to search for both "Hello" and "Goodbye" in the subject line, but I don't see how I can combine the two. Does this make sense?
August 26th, 2010 5:58pm
You may want to ask this in the Dev Forum:
http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/threads
Free Windows Admin Tool Kit Click here and download it now
August 31st, 2010 11:50pm