I wrote some codes in excel to extract information from a shared Outlook mailbox. But the codes sometime work sometimes don't although I didn't change anything. The error happen in line "Set InvFolder...". It can't find the subfolder. But it works sometimes. So weird
Can someone help me? Thanks
Can someone help me? Thanks
VBA Code:
Sub SaveInvoice()
Dim InvFolder As Outlook.Folder
Dim DoneFolder As Outlook.Folder
Set objOutlook = CreateObject("Outlook.Application")
Set objnSpace = objOutlook.GetNamespace("MAPI")
Set InvFolder = objnSpace.Folders("mysharedmailbox").Folders("Inbox").Folders("subfolderX").Folders("Invoices received")
Set DoneFolder = objnSpace.Folders("mysharedmailbox").Folders("Inbox").Folders("subfolderY").Folders("Saved Invoices")
Debug.Print DoneFolder.Name; InvFolder.name
End sub