PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Program Addins Hot to speed up MailItems access

Reply

Hot to speed up MailItems access

 
Thread Tools Rate Thread
Old 15-06-2007, 07:47 AM   #1
=?Utf-8?B?SXZhbg==?=
Guest
 
Posts: n/a
Default 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.
  Reply With Quote
Old 15-06-2007, 12:50 PM   #2
=?Utf-8?B?SXZhbg==?=
Guest
 
Posts: n/a
Default RE: How to speed up MailItems access

I've tried out this using ExMAPI -> speed was increased greatly.
  Reply With Quote
Old 15-06-2007, 07:28 PM   #3
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: 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" <Ivan@discussions.microsoft.com> wrote in message
news:CFABA54C-E7D8-43A2-8BD1-E105A424BA2D@microsoft.com...
> I've tried out this using ExMAPI -> speed was increased greatly.



  Reply With Quote
Old 26-06-2007, 06:04 AM   #4
=?Utf-8?B?SXZhbg==?=
Guest
 
Posts: n/a
Default Re: 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.

  Reply With Quote
Old 26-06-2007, 06:02 PM   #5
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: 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" <Ivan@discussions.microsoft.com> wrote in message
news:3861A9EB-E4DF-4D7C-9A2A-7AB03CF696FE@microsoft.com...
> 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.
>



  Reply With Quote
Old 27-06-2007, 04:38 AM   #6
=?Utf-8?B?SXZhbg==?=
Guest
 
Posts: n/a
Default Re: 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.

  Reply With Quote
Old 27-06-2007, 07:55 AM   #7
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: 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" <Ivan@discussions.microsoft.com> wrote in message
news:770F48FD-A2F0-48FC-A194-C073E3A909BE@microsoft.com...
> Sorry for the confusion. I mean that after calling SetColumns in OOM every
> returned item from Items collection is null.
>



  Reply With Quote
Old 27-06-2007, 09:54 AM   #8
=?Utf-8?B?SXZhbg==?=
Guest
 
Posts: n/a
Default Re: 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();
  Reply With Quote
Old 27-06-2007, 05:39 PM   #9
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: 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" <Ivan@discussions.microsoft.com> wrote in message
news:2DA20E41-8A48-4AAC-87C0-0E636026D1EC@microsoft.com...
> // 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();



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

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