> 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" <MON205[ at ]discussions.microsoft.com> wrote in message
> news:96549588-62A2-4309-82B9-FC183A4A1D9D[ at ]microsoft.com...
> > 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.
>
>
>