View Single Post
  #2  
Old March 28th 07, 07:34 PM posted to microsoft.public.outlook,microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Is Restrict Dynamic

Call Restrict, save all entry ids to a list first, then loop through your
list (rather that the restricted items collection) retrieving the items
using Namespace.GgetItemfromID.

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

"MON205" wrote in message
...
Hello,
I'm using the Items::Restrict method in my addin. I'm looping for all
mails
that I haven't processed yet depending on a user property and after
processing the mail I change this property. I found that changing property
when I loop for the restricted items affect the restricted items list.
My code is similar to:
{
_ItemsPtr pItems = NULL;
HRESULT hr = pFolder-get_Items( & pItems );
_ItemsPtr pRestrictedItems = pItems-Restrict( "NOT( [Processed] = 1" );
_MailItemPtr pMail = pRestrictedItems-GetFirst( );
long l = pRestrictedItems-GetCount( );
for( long lIndex = 0; lIndex lItemsCount; lIndex++ )
{
if( pMail )
{
//Procees Mail...
// Change the [Processed] user property to 1
// pMail-Save( );
}
}
}

When testing this code, I found that the for loop ends with lIndex = 218
where the lCount = 500.



Ads