![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
I'm currently experiencing very bad performance while iterating
through the mailitems in a folder. I have to do this to check some values in a couple of my custom properties every time a user is switching folders. I have read a lot about the Items.SetColumns() method, but can't seem to get it to work with my custom properties. This method is supposed to cache the properties you want to use, so Outlook doesn't need to open every property of every mailitem you visit. Examples of what I have tried: items.SetColumns("Storage"); // where Storage is my custom property items.SetColumns("http://schemas.microsoft/mapi/string/ {00020329-0000-0000-C000-000000000046}/Storage"); items.SetColumns("http://schemas.microsoft/mapi/id/{00020329-0000-0000- C000-000000000046}/0x8020001E"); // 8020 is according to outlook spy the tag for this property and 001E is the tag for STRING8 items.SetColumns("http://schemas.microsoft/mapi/proptag/0x8020001E"); In addition, I have tried every possible combination of the above, with no luck... Any suggestions!?? The method does work with EntryID, Subject and fields like that, but not with my custom ones.. ![]() Any help would be appreciated |
Ads |
#2
|
|||
|
|||
![]()
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. -- 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 wrote in message ups.com... I'm currently experiencing very bad performance while iterating through the mailitems in a folder. I have to do this to check some values in a couple of my custom properties every time a user is switching folders. I have read a lot about the Items.SetColumns() method, but can't seem to get it to work with my custom properties. This method is supposed to cache the properties you want to use, so Outlook doesn't need to open every property of every mailitem you visit. Examples of what I have tried: items.SetColumns("Storage"); // where Storage is my custom property items.SetColumns("http://schemas.microsoft/mapi/string/ {00020329-0000-0000-C000-000000000046}/Storage"); items.SetColumns("http://schemas.microsoft/mapi/id/{00020329-0000-0000- C000-000000000046}/0x8020001E"); // 8020 is according to outlook spy the tag for this property and 001E is the tag for STRING8 items.SetColumns("http://schemas.microsoft/mapi/proptag/0x8020001E"); In addition, I have tried every possible combination of the above, with no luck... Any suggestions!?? The method does work with EntryID, Subject and fields like that, but not with my custom ones.. ![]() Any help would be appreciated |
#3
|
|||
|
|||
![]()
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/ma...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]" wrote: 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. -- Ken Slovak [MVP - Outlook]http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm wrote in message ups.com... I'm currently experiencing very bad performance while iterating through the mailitems in a folder. I have to do this to check some values in a couple of my custom properties every time a user is switching folders. I have read a lot about the Items.SetColumns() method, but can't seem to get it to work with my custom properties. This method is supposed to cache the properties you want to use, so Outlook doesn't need to open every property of every mailitem you visit. Examples of what I have tried: items.SetColumns("Storage"); // where Storage is my custom property items.SetColumns("http://schemas.microsoft/mapi/string/ {00020329-0000-0000-C000-000000000046}/Storage"); items.SetColumns("http://schemas.microsoft/mapi/id/{00020329-0000-0000- C000-000000000046}/0x8020001E"); // 8020 is according to outlook spy the tag for this property and 001E is the tag for STRING8 items.SetColumns("http://schemas.microsoft/mapi/proptag/0x8020001E"); In addition, I have tried every possible combination of the above, with no luck... Any suggestions!?? The method does work with EntryID, Subject and fields like that, but not with my custom ones.. ![]() Any help would be appreciated |
#4
|
|||
|
|||
![]()
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/ma...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]" wrote: 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. -- Ken Slovak [MVP - Outlook]http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm wrote in message ups.com... I'm currently experiencing very bad performance while iterating through the mailitems in a folder. I have to do this to check some values in a couple of my custom properties every time a user is switching folders. I have read a lot about the Items.SetColumns() method, but can't seem to get it to work with my custom properties. This method is supposed to cache the properties you want to use, so Outlook doesn't need to open every property of every mailitem you visit. Examples of what I have tried: items.SetColumns("Storage"); // where Storage is my custom property items.SetColumns("http://schemas.microsoft/mapi/string/ {00020329-0000-0000-C000-000000000046}/Storage"); items.SetColumns("http://schemas.microsoft/mapi/id/{00020329-0000-0000- C000-000000000046}/0x8020001E"); // 8020 is according to outlook spy the tag for this property and 001E is the tag for STRING8 items.SetColumns("http://schemas.microsoft/mapi/proptag/0x8020001E"); In addition, I have tried every possible combination of the above, with no luck... Any suggestions!?? The method does work with EntryID, Subject and fields like that, but not with my custom ones.. ![]() Any help would be appreciated |
#5
|
|||
|
|||
![]()
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. -- 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 wrote in message ups.com... 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/ma...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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Hot to speed up MailItems access | Ivan | Add-ins for Outlook | 8 | June 27th 07 05:39 PM |
Move MailItems to another folder | Gvaram | Outlook and VBA | 5 | June 25th 07 12:46 PM |
Deleting Duplicate Mailitems | Geoff | Outlook and VBA | 7 | October 19th 06 04:21 PM |
Sending MailItems from Outbox part 2 | Tom at GSD | Add-ins for Outlook | 6 | September 14th 06 06:42 PM |
How To: select mailitems from my inbox? | NFR | Outlook - Using Forms | 1 | May 16th 06 03:41 PM |