Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   Hot to speed up MailItems access (http://www.outlookbanter.com/add-ins-outlook/50515-hot-speed-up-mailitems-access.html)

Ivan June 15th 07 07:47 AM

Hot to speed up MailItems access
 
I get some properties from each MailItem in some folder:

_ItemsPtr spItems = spFolder-Items;
for (int j = 0; j spItems-Count; j++)
{
_MailItemPtr spMailItem = spItems-Item( j+1 );
if ( !spMailItem )
continue;

// SenderEmailAddress, SenderName, SentOn, Subject and Recipients
properties reading here
}

But this code is very slow. Only 130 messages per second even without
reading any properties.

How can I speed up mail items processing greatly? I need to process
thousands of emails...

Thanks.

Ivan June 15th 07 12:50 PM

How to speed up MailItems access
 
I've tried out this using ExMAPI - speed was increased greatly.

Dmitry Streblechenko June 15th 07 07:28 PM

How to speed up MailItems access
 
Have a look at the Items.SetColumns methods.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Ivan" wrote in message
...
I've tried out this using ExMAPI - speed was increased greatly.




Ivan June 26th 07 06:04 AM

How to speed up MailItems access
 
Thanks, Dmitry!
When I tried to use this method in OOM it always returns null. I don't know
why.
Using MAPI, IMAPITable.SetColumns works fine.


Dmitry Streblechenko June 26th 07 06:02 PM

How to speed up MailItems access
 
I am not sure what you mean - SetColumns in OOM does not return anything; it
simply tells Outlook which properties you are planning to access later from
the Items collection so that Outlook can make sure these properties get
cached from the underlying MAPI table.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Ivan" wrote in message
...
Thanks, Dmitry!
When I tried to use this method in OOM it always returns null. I don't
know
why.
Using MAPI, IMAPITable.SetColumns works fine.




Ivan June 27th 07 04:38 AM

How to speed up MailItems access
 
Sorry for the confusion. I mean that after calling SetColumns in OOM every
returned item from Items collection is null.


Dmitry Streblechenko June 27th 07 07:55 AM

How to speed up MailItems access
 
What is your code?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Ivan" wrote in message
...
Sorry for the confusion. I mean that after calling SetColumns in OOM every
returned item from Items collection is null.




Ivan June 27th 07 09:54 AM

How to speed up MailItems access
 
// spFolder - MAPIFolderPtr
_ItemsPtr spItems = spFolder-Items;
spItems-SetColumns( "SenderName" );
for (int j = 0; j spItems-Count; j++)
{
_MailItemPtr spMailItem = spItems-Item( j+1 );
// spMailItem == null always, but without calling SetColumns everything
is ok.

if ( !spMailItem )
continue;
}
spItems-ResetColumns();

Dmitry Streblechenko June 27th 07 05:39 PM

How to speed up MailItems access
 
I had no problem running rthe script below (I used OutlookSpy - click
"Script Editor" button, paste the script, click Run)
What is your version of Outlook? What happens if you declare spMailItem as
IDispatch instead of _MailItemPtr?
Note that your code will fail if you encounter an item other than MailItem
(such as ReportItem).

set Folder = Application.ActiveExplorer.CurrentFolder
set Items = Folder.Items
Items.SetColumns("SenderName")
for each Item in Items
Debug.Print Item.SenderName
next

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Ivan" wrote in message
...
// spFolder - MAPIFolderPtr
_ItemsPtr spItems = spFolder-Items;
spItems-SetColumns( "SenderName" );
for (int j = 0; j spItems-Count; j++)
{
_MailItemPtr spMailItem = spItems-Item( j+1 );
// spMailItem == null always, but without calling SetColumns everything
is ok.

if ( !spMailItem )
continue;
}
spItems-ResetColumns();





All times are GMT +1. The time now is 12:32 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-2006 OutlookBanter.com