By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,261 Members | 1,317 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,261 IT Pros & Developers. It's quick & easy.

How can I loop through all of the messages in the inbox - VB.NET E

P: n/a
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.olFol derInbox)

'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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Crouchie:

Can't thank you enough, copying the code in the first article and pasting
it worked just like it should. I don't understand quite why, as the code I
was using came directly from a book, and worked in VBA, but not in .NET.
Must have something to do with how it was being initialized, or the way it
was put together. I thought it was maybe a bug in vb.net. Don't know why it
works, but at this point, don't care, and again.... Thank you

jf
"Crouchie1998" wrote:
Try these two:

http://support.microsoft.com/default...b;en-us;313795

http://support.microsoft.com/default...b;en-us;313800

Here is the best site for you though:

http://www.add-in-express.com/support/addin-vb-net.php

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.