
Outlook97 - Access97 Reading Mail Items in inbox
Thanks again Sue, I am at office at present and Outlook
VBA help is not installed, hence my questions, it takes
fore-ever to get IT support to do anything here, so I was
just being impatient to get on, I can look it up when I
get home where I have neccessary help files on my home PC
Thanks again for your help.
Regards
Ken Reay
Quote:
>-----Original Message-----
>You should always Dim the variable used for items in an
Outlook folder as
>Object, not as a specific item type. Why? The Inbox can
contain other types
>of items -- meeting requests, NDRs, task requests.
>I just looked up the Outlook 97 object model (which you
can do yourself in
>the VBA object browser), and it doesn't support the Class
property. I think
>you can use the TypeName() function instead.
>> Thanks Sue
>> With your assistance I have moved on a step.
>> But now I am getting Error 438 Object does not
support...
>> on the line 'If objItem.Class = olMailItem ' below
>> Do I need to define objItem more explicitly (ie as an
>> Outlook type?)
>> Dim olApp As Outlook.Application
>> Dim olNS As Outlook.NameSpace
>> Dim olMail As MailItem
>> Dim olFolder As Outlook.MAPIFolder
>> Dim olFlds As Outlook.Folders
>> Dim i As Integer
>> Dim olItems As Outlook.Items
>> Dim objItem As Object
>> '
>> On Error GoTo Error_MailItems
>> Set olApp = GetObject("Outlook.Application")
>> Set olNS = olApp.GetNamespace("MAPI")
>> olNS.Logon
>> Set olFolder = olNS.GetDefaultFolder(olFolderInbox)
>> For Each objItem In olFolder.Items
>> If objItem.Class = olMailItem Then
>> End If
>> Next
>> >-----Original Message-----
>> >You're on the right track. To get the Inbox, use the
>> >Namespace.GetDefaultFolder method:
>> > Set olFolder = olNS.GetDefaultFolder
>> (olFolderInbox) ' 6
>> >To work with the items in the Inbox, use a For Each
loop:
>> > For Each objItem in olFolder.Items
>> > ' so something with objItem
>> > Next
>> >You cannot assume that every objItem is a MailItem.
Test
>> the .Class property
>> >before using any MailItem-specific properties or
methods.
>> >See http://www.slipstick.com/dev/vb.htm for more basic
>> Outlook code.
>> >--
>> >Sue Mosher, Outlook MVP
>> > Outlook and Exchange Solutions
>> > at http://www.slipstick.com
>> >> I am attempting to extract data the body of a series
of
>> >> Emails.
>> >> Incomming EMails are located (unsurprisingly) in the
>> >> inbox, I want to interate through them and read the
body
>> >> of each Email, from Access97 via vba.
>> >> I have made the Access97/Outlook97 connection and
worked
>> >> my way partway thru the resulting objects, how do I
get
>> to
>> >> the InBox folder, and then to the Mail items?
>> >> Code so far is:
>> >> Dim olApp As Outlook.Application
>> >> Dim olNS As Outlook.NameSpace
>> >> Dim olMail As MailItem
>> >> Dim olFolder As Outlook.MAPIFolder
>> >> Dim olFlds As Outlook.Folders
>> >> Dim i As Integer
>> >> '
>> >> On Error GoTo Error_MailItems
>> >> Set olApp = GetObject("Outlook.Application")
>> >> Set olNS = olApp.GetNamespace("MAPI")
>> >> olNS.Logon
>> >> Set olFlds = olNS.Folders("Personal
>> Folders").Folders
>> >> Thanks in advance
>> >> Ken Reay
>> >.
>.