Process all items in inbox with VB.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Ferree

    Process all items in inbox with VB.NET

    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\waNOTI FICATION\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_C lick(ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles btnProcessMsg.C lick
    ' Declare variables
    Dim objApp As Outlook.Applica tion
    Dim ns As Outlook.NameSpa ce
    Dim Inbox As Outlook.MAPIFol der
    Dim Item As Object
    Dim i As Integer

    ns = objApp.GetNames pace("MAPI")
    Inbox = ns.GetDefaultFo lder(Outlook.Ol DefaultFolders. 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


Working...