Found Shared Inbox but can't identify the MailItems

J

James.Ramsay

Quick background… I am trying to develop an application for a company in the
UK… only I now live in Australia!! I am attempting to write some code that
looks at the items in a Shared Inbox and downloads attachments. I have the
code working for my own inbox here in Australia (SMTP) but can’t tailor it
for the guys in the UK. I am running this from an Access 2003 database (I
have outlook 2003 installed as does the company… not sure what type of
exchange server they have)

The test code that I have at the moment is…

Public Function Test()
Dim olApp As outlook.Application
Dim olMAPIFolder As outlook.MAPIFolder
Dim olMAPIMailItem As outlook.MailItem
Dim olMAPIMailAtmt As outlook.Attachment

PROC_START:
On Error Goto PROC_ERROR

PROC_MAIN:
Set olApp = outlook.Application
Set olMAPIFolder = GetFolder("Mailbox - ~ NW Prospect Reports\Inbox")
'Sue Mosher

‘AddToLog is a one-liner that outputs the info to a logfile
AddToLog strLogFile1, "FolderPath: " & olMAPIFolder.FolderPath & vbCrLf
AddToLog strLogFile1, "DefaultMessageClass: " &
olMAPIFolder.DefaultMessageClass & vbCrLf
AddToLog strLogFile1, "EntryId: " & olMAPIFolder.EntryID & vbCrLf
AddToLog strLogFile1, "StoreId: " & olMAPIFolder.StoreID & vbCrLf
AddToLog strLogFile1, "FolderName: " & olMAPIFolder.Name & vbCrLf
AddToLog strLogFile1, "UnreadItems: " & olMAPIFolder.UnReadItemCount &
vbCrLf
AddToLog strLogFile2, "DefaultItemType: " & olMAPIFolder.DefaultItemType
& vbCrLf

‘>> The bit below doesn’t seem to work…
If olMAPIFolder.Items.Count > 0 Then
For Each olMAPIMailItem In olMAPIFolder.Items
For Each olMAPIMailAtmt In olMAPIMailItem.Attachments
If olMAPIMailAtmt.Type = olByValue Then 'Ignore
embedded files
‘ => Get details of any attachments here and save
as strAttachment
End If
Next olMAPIMailAtmt
' => Output details of emails and attachments to a logfile for review
(Subject, etc)
Next olMAPIMailItem
End If

PROC_EXIT:
On Error Resume Next
Set olMAPIFolder = Nothing
Set olApp = Nothing
DoCmd.Hourglass False
Exit Function

PROC_ERROR:
MsgBox Err.Number & ": " & Err.Description
Resume PROC_EXIT
Exit Function

I think that this is identifying the folder correctly and it returns the
following results:

FolderPath: \\Mailbox - ~ NW Prospect Reports\Inbox
DefaultMessageClass: IPM.Note
EntryId: ...05A8A9D0C13AE184A922A0A26238... etc
StoreId: ...032005600300031002E007200620... etc
FolderName: Inbox
UnreadItems: 4
DefaultItemType: 0

Can you see any reason why the middle bit of the code is unable to identify
the actual email items?!

Hopefully this is really obvious to someone else!!

Thanks in Advance...

James
 
B

Brian Tillman [MVP - Outlook]

Quick background… I am trying to develop an application for a company in the
UK… only I now live in Australia!! I am attempting to write some code that
looks at the items in a Shared Inbox and downloads attachments.

Programming questions and discussions should be posted to
microsoft.public.outlook.program_vba or .program_addins.
 
Top