According to the Object Browser Help on SetColumns using EntryID will cause
an error.
If your user properties have been added to the folder and not just the items
you can use a filter or restriction if you're looking for specific values in
the user properties (for example a user property that has the value True).
Are you just using the Outlook object model or are you also using an
alternate API such as Redemption? If you're using Redemption or Outlook 2007
you could set up a request for a MAPITable object that just returns the
columns represented by your user properties plus anything else you might
need such as EntryID, that would be extremely fast, probably about an order
of magnitude faster than any method using the Outlook object model. You
could also filter or restrict that returned table object for even faster
performance.

Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> I'm currently experiencing very bad performance while iterating
> through the mailitems in a folder. I have to do this to check some
[quoted text clipped - 24 lines]
>
> Any help would be appreciated
jorgen.slettahjell@gmail.com - 26 Sep 2007 13:36 GMT
Thank you very much for your response Ken :)
Yes, I am using Redemption, and I have tried to replicate the code on
this page < http://www.dimastr.com/redemption/mapitable.htm#tablefiltering
> to suit my c# project.
Now, what I need to do is to understand what I am supposed to do with
the result of this. I have investigated the "rows" variable, which
turns out to be a System.Array object including data from my
mailitems.
Here is my code:
int [] columns = new int[3];
Outlook.Items items = selectedFolder.Items;
Redemption.SafeMailItem safeMail = new Redemption.SafeMailItem();
safeMail.Item = items[1];
int cmTag = safeMail.GetIDsFromNames("{00020329-0000-0000-
C000-000000000046}", "Storage");
cmTag = cmTag + 0x001E;
columns[0] = cmTag;
cmTag = safeMail.GetIDsFromNames("{00020329-0000-0000-
C000-000000000046}", "RID");
cmTag = cmTag + 0x001E;
columns[1] = cmTag;
cmTag = safeMail.GetIDsFromNames("{00020329-0000-0000-
C000-000000000046}", "Account");
cmTag = cmTag + 0x001E;
columns[2] = cmTag;
Redemption.MAPITable mapiTable = new Redemption.MAPITable();
mapiTable.Item = items;
mapiTable.Columns = columns;
mapiTable.GoToFirst();
object rows = mapiTable.GetRows(mapiTable.RowCount);
Now, my next step is to decrypt the rows variable. I guess I have to
cast it to System.Array and try to get hold of the data in it.
Then I will have to iterate through the data, and pick up the
mailitems that fit my criteria and then do whatever I need to do with
them.
Can you verify to me that this is the right approach?
If you have a tip on how to include EntryID of messages to the columns
filter and how to get hold of the message by using this EntryID, I'd
appreciate it very much :)
J?rgen
On 25 Sep, 16:16, "Ken Slovak - [MVP - Outlook]" <kenslo...@mvps.org>
wrote:
> According to the Object Browser Help on SetColumns using EntryID will cause
> an error.
[quoted text clipped - 50 lines]
>
> > Any help would be appreciated
Ken Slovak - [MVP - Outlook] - 26 Sep 2007 14:42 GMT
The approach is correct but I'd probably loop the table and not use GetRows
unless I was positive I was getting a limited number of rows back. I'd
either use GetRows(20) or GetRow, since MAPI has limitations on how much
data it can return in one pass.
EntryID is really a PT_BINARY property, so when you get it back you will
need to use HrArrayToString to convert it to a string value. If it's
possible that Exchange is involved you also have to ask for both the
short-term and long-term id's and check for an empty value on long-term
before checking for short-term. If you only have a PST file to query then
you can just use EntryID (PR_ENTRYID = 0x0FFF0102).
const int PR_ENTRYID = 0x0FFF0102;
const int PR_LONGTERM_ENTRYID_FROM_TABLE = 0x66700102;
Probably just for clarity I'd also Or the property type with the tag instead
of using an addition operator, but that's more a matter of style.
After you have the EntryID for an item retrieving the item is simple using
the NameSpace.GetItemFromID() method.

Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
Thank you very much for your response Ken :)
Yes, I am using Redemption, and I have tried to replicate the code on
this page < http://www.dimastr.com/redemption/mapitable.htm#tablefiltering
> to suit my c# project.
Now, what I need to do is to understand what I am supposed to do with
the result of this. I have investigated the "rows" variable, which
turns out to be a System.Array object including data from my
mailitems.
Here is my code:
int [] columns = new int[3];
Outlook.Items items = selectedFolder.Items;
Redemption.SafeMailItem safeMail = new Redemption.SafeMailItem();
safeMail.Item = items[1];
int cmTag = safeMail.GetIDsFromNames("{00020329-0000-0000-
C000-000000000046}", "Storage");
cmTag = cmTag + 0x001E;
columns[0] = cmTag;
cmTag = safeMail.GetIDsFromNames("{00020329-0000-0000-
C000-000000000046}", "RID");
cmTag = cmTag + 0x001E;
columns[1] = cmTag;
cmTag = safeMail.GetIDsFromNames("{00020329-0000-0000-
C000-000000000046}", "Account");
cmTag = cmTag + 0x001E;
columns[2] = cmTag;
Redemption.MAPITable mapiTable = new Redemption.MAPITable();
mapiTable.Item = items;
mapiTable.Columns = columns;
mapiTable.GoToFirst();
object rows = mapiTable.GetRows(mapiTable.RowCount);
Now, my next step is to decrypt the rows variable. I guess I have to
cast it to System.Array and try to get hold of the data in it.
Then I will have to iterate through the data, and pick up the
mailitems that fit my criteria and then do whatever I need to do with
them.
Can you verify to me that this is the right approach?
If you have a tip on how to include EntryID of messages to the columns
filter and how to get hold of the message by using this EntryID, I'd
appreciate it very much :)
Jørgen
jorgen.slettahjell@gmail.com - 26 Sep 2007 13:36 GMT
Thank you very much for your response Ken :)
Yes, I am using Redemption, and I have tried to replicate the code on
this page < http://www.dimastr.com/redemption/mapitable.htm#tablefiltering
> to suit my c# project.
Now, what I need to do is to understand what I am supposed to do with
the result of this. I have investigated the "rows" variable, which
turns out to be a System.Array object including data from my
mailitems.
Here is my code:
int [] columns = new int[3];
Outlook.Items items = selectedFolder.Items;
Redemption.SafeMailItem safeMail = new Redemption.SafeMailItem();
safeMail.Item = items[1];
int cmTag = safeMail.GetIDsFromNames("{00020329-0000-0000-
C000-000000000046}", "Storage");
cmTag = cmTag + 0x001E;
columns[0] = cmTag;
cmTag = safeMail.GetIDsFromNames("{00020329-0000-0000-
C000-000000000046}", "RID");
cmTag = cmTag + 0x001E;
columns[1] = cmTag;
cmTag = safeMail.GetIDsFromNames("{00020329-0000-0000-
C000-000000000046}", "Account");
cmTag = cmTag + 0x001E;
columns[2] = cmTag;
Redemption.MAPITable mapiTable = new Redemption.MAPITable();
mapiTable.Item = items;
mapiTable.Columns = columns;
mapiTable.GoToFirst();
object rows = mapiTable.GetRows(mapiTable.RowCount);
Now, my next step is to decrypt the rows variable. I guess I have to
cast it to System.Array and try to get hold of the data in it.
Then I will have to iterate through the data, and pick up the
mailitems that fit my criteria and then do whatever I need to do with
them.
Can you verify to me that this is the right approach?
If you have a tip on how to include EntryID of messages to the columns
filter and how to get hold of the message by using this EntryID, I'd
appreciate it very much :)
J?rgen
On 25 Sep, 16:16, "Ken Slovak - [MVP - Outlook]" <kenslo...@mvps.org>
wrote:
> According to the Object Browser Help on SetColumns using EntryID will cause
> an error.
[quoted text clipped - 50 lines]
>
> > Any help would be appreciated