外表.将文件夹添加到收藏夹组
我现在正在处理Outlook宏,以将选定的文件夹添加到Outlook的收藏夹"组中. 我尝试使用这种方法
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
但是AddToPFFavorites方法抛出错误尝试的操作失败.找不到对象".
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.
我的问题是: 如何将文件夹添加到收藏夹组? 在收藏夹中显示"操作的VBA等效项是什么?
My question is: How to add folder to favorites group? What is VBA equivalent for "Show in Favorites" action?
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);