Process all items in inbox in VB.NET

J

Jason Ferree

I posetd this in one group, but got no response, so I'll try it in this one.

I am trying to loop through all messages in the inbox. To do something, in
my case, look for and save attachments.
It is telling me that items is not a collection. I've tried everything I
can think of, I've even copied the code from a few sources (had to add
specific OOM in front of method names), Including Sues book, some code from
www.outlookcode.com, and one other place. but other than that, no change to
copied code. I think the problem is I've
looked at this so long that I just can't see the forrest for the trees
anymore. So... Any help anyone could provide would be most appreciated. Is
this a problem with Visual Studio? I can't find any reference to it anywhere.

OS: Windows 2000
Dev Env: Visual Studio.net 2003
(visual basic.net)
Outlook Version: Outlook 2000
(Utilizing outlook 9.0 Object Libarary
as reference to project)

Objective: Loop through all messages in inbox (for test) - eventually, from
another folder - but I have that figured out. Save attachments to disk, if
they exist. This is a subroutine of a bigger project, but, most of that is
working.

Problem: In the portion of the code, labeled ***PROBLEM***, it gives me the
following error:
"D:\Visual Studio Projects\waNOTIFICATION\Form1.vb(942): Expression is of
type 'Outlook.Items', which is not a collection type."


The code for the routine is below.

Private Sub btnProcessMsg_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnProcessMsg.Click
' Declare variables
Dim objApp As Outlook.Application
Dim ns As Outlook.NameSpace
Dim Inbox As Outlook.MAPIFolder
Dim Item As Object
Dim i As Integer

ns = objApp.GetNamespace("MAPI")
Inbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)

'PROBLEM IS HERE - THE NEXT LINE IS THE ONE
WITH THE ERROR -
'SPECIFICALLY - SQUIGGLY LINES UNDER INBOX.ITEMS
(SO IT IS NOT RECOGNIZING IT,
'OR IT IS, BUT IT THINKS ITS IN ERROR

For Each Item In Inbox.Items
'PROCESS MESSAGE HERE - GET SUBJECT, OR WHATEVER
Next Item
End Sub

Thank you in advance

Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top