I am working on an Outlook VBA application and I need to access my mailbox, but it seems to be having problems. I use the method GetDefaultFoldder(olFolderInbox), but I have several email addresses configured and none of them appear in the My Personal Folders folder.
So my question is: where is this folder defined by default? How do I know which mailbox is standard? I know that there is a method GetFolderFromID, if I used this,
how can i find the folder id to point to it?
Here is the code I'm using. This is from a Timothy Chen Allen blog tutorial, as shown here by Timothy's Blog . The code:
Sub find_unread()
On Error GoTo eh:
Dim ns As Outlook.NameSpace
Dim folder As MAPIFolder
Dim item As Object
Dim msg As MailItem
Set ns = Session.Application.GetNamespace("MAPI")
Set folder = ns.GetDefaultFolder(olFolderInbox)
For Each item In folder.Items
DoEvents
If (item.Class = olMail) And (item.UnRead) Then
Set msg = item
Debug.Print msg.SenderEmailAddress
msg.Display True
End If
Next
MsgBox "All messages in Inbox are read", vbInformation, "All Read"
Exit Sub
eh:
MsgBox Err.Description, vbCritical, Err.Number
End Sub