petermeachem
Programmer
Code:
Set olApp = New Outlook.Application
Set olNamespace = olApp.GetNamespace("MAPI")
Set olFolder = olNamespace.Folders("Mailbox - Applications").Folders("Inbox")
Set olMail = olFolder.Items.GetFirst
jNoEmails = olFolder.Items.Count
For J = 1 To jNoEmails
Set olMail = olFolder.Items(J)
If Format(olMail.CreationTime, "dd mmm yyyy") = Format(Now(), "dd mmm yyyy") Then
A = olMail.SenderName
c = olMail.body
jCount = jCount + 1
Else
Exit For
End If
Next J
Set olFolder = Nothing
Set olNamespace = Nothing
Set olApp = Nothing
I've not tried to do this before. Every thing I've googled says something like this should work, in my case not. It stops on the Set olMail = olFolder.Items(J) line, currently consistently for j = 7 but it has varied throughout the day. The Applications mailbox has 1400 records and it is a mailbox added to my outlook. the error is 'Type mismatch'. olFolder.Items(J) contains the subject line, same as on the previous records.
What it is doing is stopping where the from address is not Applications. Most of the emails are from Applications, unfortunately i'm trying to read bounces which won't be.
Can anyone come up with an explanation? Exchange is 2008, my outlook is 2003 and this mailbox is an additional mailbox.