A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Is Restrict Dynamic



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 28th 07, 02:50 AM posted to microsoft.public.outlook,microsoft.public.outlook.program_addins
MON205
external usenet poster
 
Posts: 31
Default Is Restrict Dynamic

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
  #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.



  #3  
Old April 4th 07, 05:34 PM posted to microsoft.public.outlook,microsoft.public.outlook.program_addins
MON205
external usenet poster
 
Posts: 31
Default Is Restrict Dynamic

Thanks a lot for your reply.
I found that the Items collection is a dynamic collection!!!!
You can find strange things he
http://msdn2.microsoft.com/en-us/lib...tions_restrict


....
"Dmitry Streblechenko" wrote:

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.




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Restrict Dynamic MON205 Outlook - General Queries 2 April 4th 07 05:34 PM
Dynamic result by recipient’s name Pari Outlook and VBA 5 February 12th 07 09:09 PM
Is a dynamic Map to location possible? Angyl Outlook - Using Forms 0 July 5th 06 07:00 PM
embedding dynamic data in signature file don vito Outlook and VBA 3 June 14th 06 07:12 AM
Outlook 2003 Dynamic signatures TheHealingLotus Outlook - General Queries 1 March 9th 06 01:38 PM


All times are GMT +1. The time now is 12:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.