Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Is Restrict Dynamic

Geek News

Is Restrict Dynamic
MON205 3/28/2007 12:50:23 AM
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.
Re: Is Restrict Dynamic
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 3/28/2007 5:34:00 PM
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...
[Quoted Text]
> 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.


Re: Is Restrict Dynamic
MON205 4/4/2007 3:34:01 PM
Thanks a lot for your reply.
I found that the Items collection is a dynamic collection!!!!
You can find strange things here: http://msdn2.microsoft.com/en-us/library/aa155748(office.10).aspx#olcollections_restrict


....
"Dmitry Streblechenko" wrote:

[Quoted Text]
> 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.
>
>
>

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