Folder.Items collection in .NET

  • Thread starter Thread starter Juan Romero
  • Start date Start date
J

Juan Romero

Guys,

I am writing a COM Add-in for Outlook using VB.NET. Everything goes well
until the add-in tries to get a reference to an instance of an e-mail. It
returns a "Internal Application Error" on the exception message.

One thing I noticed is that the collections such as folder.items are not
available through the Interop. If I try to run a loop on the items of this
collection for example, I get an error saying folder.items is not a
collection type. However, in other instances, I have been able to access the
items contained in this collection by directly referencing the item (e.g.
folder.items.item(1)). I cannot do that here. It yields an error. What is
even more weird is that I am able to get the count of items inside the
folder, so I know that I do have a valid instance of the given folder, but I
can't access the items.

Here is the code:

Dim a As Long
Dim oJunk As Outlook.MAPIFolder = GetFolder("Junk E-Mail", oFolder, False)
Dim oMail As Object
Trace.WriteLine(oFolder.Items.Count)
For a = 1 To oFolder.Items.Count
oMail = oFolder.Items.Item(a)
'Returns error when trying to evaluate line above

This is running as a separate thread.
Any ideas?
 
Try posting to a developer newsgroup like:

microsoft.public.outlook.program_addins

- J.
 
Back
Top