Searching Inbox for e-mails with a specific subject

Add-in Express™ Support Service
That's what is more important than anything else

Searching Inbox for e-mails with a specific subject
David Anson

Posts: 8
Joined: 2004-11-22
I am needing to go to a particular folder in Outlook (say the Inbox) and scroll through the e-mails therein and read the subject lines.

I can get so far as even being able to succesfully count the number of items in the folder using {_Items}.Count but then when I try to loop through the items I get stuck.

It works OK the first time through when:

OLItem := OutlookApp.ActiveExplorer.Selection.Item(1)

but when the number increments to 2 I get an array out of bounds error even though the count shows there are 6 items.

Any ideas? :evil:
Posted 03 Dec, 2004 06:39:34 Top
Dmitry Kostochko

Add-in Express team

Posts: 2875
Joined: 2004-04-05
Hello David,

To scan items in a particular folder you don't need to use the Selection collection. Try the following code:

for i := 1 to OutlookApp.ActiveExplorer.CurrentFolder.Items.Count do
OLItem := OutlookApp.ActiveExplorer.CurrentFolder.Items.Item(i);

Does OutlookApp.ActiveExplorer.Selection.Count return 6? Or does OutlookApp.ActiveExplorer.CurrentFolder.Items.Count return 6?

Posted 03 Dec, 2004 07:17:04 Top
David Anson

Posts: 8
Joined: 2004-11-22
That has worked gret. Thanks for your help.

David Anson
Posted 03 Dec, 2004 11:55:17 Top