Array of Outlook Items?

  • Thread starter Thread starter John Riddle
  • Start date Start date
J

John Riddle

Hello,

Does anyone know if I could populate an array with Outlook items such as:

Dim myArray()
Dim myItem As MailItem 'Or Object?
Dim myItems As Outlook.Items

Set myItems = Application.Session.GetDefaultFolder(olFolderInboxItems).Items
i = 0
For Each myItem in MailItems
ReDim myArray(i)
Set myArray(i) = myItem.Item
i = i +1
Next

Set oItem = myArray(3) 'assuming that there are several items in the array
oItem.Display

This is a very simplified example. Obviously, without a restriction on the
MailItems I could just use the index of the MailItems collection to retrieve
the item and not bother with the array at all. What I'm actually doing is
using the Find/FindNext methods to populate an array with items themselves
instead of just some properties of the items.

Can this be done?

Thanks,

John
 
Hi John,

from the view of an array you can do so. (And you can Dim the array as
MailItem, too.) But, AFAIK, from the view of OL it is possible that you
can´t if there are a lot of references to be held. (At least in OL2k
I´ve experienced that.) Therefor I often just store the EntryIDs in the
array (then it would be dimmed as String, of course).

BTW, if I may give you tipp: You know the needed size for the array at
the beginning, so you should resize it at once because that is *very*
much faster.
 
Back
Top