Hi Guy's , i am trying to open an email inbox from a command button, how do i open a specific inbox and refresh a list and i don't have reference to MAPi folder, unsure what reference Library this is in ?
I copied this code and pasted to a command button on click
I have x 7 inbox folders but i want to open a specific folder, lets call the inbox i want to open work@ any ideas
Much appreciated
Code:
Const olFolderInbox = 6
Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
Set InboxItems = Inbox.Items
For Each Mailobject In InboxItems
End If
Next
Me.lstEmails.Requery
Error_Handler_Exit:
'cleanup ->
Set OlApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
Exit Sub
Error_Handler:
MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: ReadInbox" & vbCrLf & _
"Error Description: " & Err.Description, _
vbExclamation, "An Error has Occurred!"
Resume Error_Handler_Exit