Runtime error. Attempted VBA Outlook operation failed

I created a macro to run a routine in outlook. The code works perfectly on a PC, but when I go to replicate the code to another macro I get the following message:

Runtime Error ' -2147221233 (8004010f) Failure of the attempted operation. Object not found

The error looks like in the following snippet:

Set ol = New Outlook.Application
Set ns = ol.GetNamespace("MAPI")

'Erro aqui:
Set fol_CGR = ns.Folders(1).Folders("CGR")
Set fol_UDI = ns.Folders(1).Folders("UDI")

I've read several forums and found nothing similar. Can anyone help me?

Author: gabrielfvds, 2019-12-20

1 answers

The problem was solved by explaining the address of the default folder

Set fol_CGR = ns.Folders(1).Folders("Pasta")

Replaced by

Set fol_CGR = ns.Folders("[email protected]").Folders("CGR")
 0
Author: gabrielfvds, 2019-12-20 14:39:07