I'm working now on Outlook macros to add selected folder to Outlook's favorites group. I've tried to use this method
Sub AddToFavorites()
Dim olapp As Outlook.Application
Dim objFolder As Outlook.MAPIFolder
Set olapp = New Outlook.Application
Set objFolder = olapp.ActiveExplorer.CurrentFolder
objFolder.AddToPFFavorites
End Sub
But AddToPFFavorites method throws error "The attempted operation failed. An object could not be found".
I've tried to add target folder to favorites using "Show in Favorites" action from context menu, as result folder has been showed in Favorites group without errors.
My question is: How to add folder to favorites group? What is VBA equivalent for "Show in Favorites" action?
To add a folder to FavoritesDrag and drop it. Right click the folder and choose the Add to Favorites option. Click the folder to select it, then choose Folders > Add to Favorites from the ribbon.
Select Favorites, Organize Favorites from the menu bar. Select the appropriate Home Page for the new folder. Click New Folder. Enter a name and description for the folder and click OK.
Tip: If the Favorites command is missing, you are probably in a special view known as the Folder List, not Mail. On the navigation bar, click Mail. Favorites, located at the top of Navigation Pane, contains shortcuts to folders that you frequently use.
Microsoft 365 Groups users will be able to create folders inside the Groups section in mail area of Outlook on the web. You will be able to move and copy messages across different folders inside the Group.
You can manage the Outlook favorites group by accessing the NavigationPane
mail module.
Outlook.MailModule mailModule = ThisAddIn.Application.ActiveExplorer().NavigationPane.Modules.GetNavigationModule(Outlook.OlNavigationModuleType.olModuleMail) as Outlook.MailModule;
Outlook.NavigationGroup favGroup = mailModule.NavigationGroups.GetDefaultNavigationGroup(Outlook.OlGroupType.olFavoriteFoldersGroup);
favGroup.NavigationFolders.Add(objFolder);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With