I've managed to retrieve mails from the shared inbox using the following code
Sub GetFromOutlook()
Dim OutlookApp As Outlook.Application
Dim oaccount As Outlook.Account
Dim OutlookNamespace As Namespace
Dim ostore As Outlook.Store
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer
MailBoxName = "support@company.com"
Set OutlookApp1 = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set objOwner = OutlookNamespace.CreateRecipient(accName)
objOwner.Resolve
If objOwner.Resolved Then
Set Folder = OutlookNamespace.GetSharedDefaultFolder(objOwner, olFolderInbox).Folders("IL").Folders("5")
However, when I try to change the MailBoxName = "support@company.com" to "sales@company.com" later on in the code, I get the following error:
Run-time error -2147221219 (8004011d)
The operation failed because of a registry or installation problem. Restart Outlook andtry again.If the problem persists, reinstall.
It is if like Excel/Outlook remembers the connection. Can someone help with this problem?