Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outlook. Add folder to favorites group

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?

like image 484
GothAr Avatar asked Oct 17 '12 13:10

GothAr


People also ask

How do I add a folder and subfolders to favorites in Outlook?

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.

Can I make folders for my favorites?

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.

Why don't I have a favorites folder in Outlook?

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.

Can you create folders in Outlook groups?

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.


1 Answers

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);
like image 198
SliverNinja - MSFT Avatar answered Oct 23 '22 14:10

SliverNinja - MSFT