'Reference a shared inbox account

On a shared inbox account, I would like to run a script if the email is unread.

I tried this:

Sub UnreadMail()

 Dim myEmail As Object
 Dim myNamespace As Object
 Dim myFolder As Folder

 Set myNamespace = Application.GetNamespace("MAPI")
 Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)

For Each myEmail In myFolder
 If (myEmail.UnRead) Then
  Call SaveAttachToDisk
 End If
 Next
End Sub


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source