Outlook
--
Questions
--
Followers
Top Experts
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
If you have Outlook 2007, then this will work. Â Not aware of any way to do this via code with older versions of Outlook. Â
Sub AddFavoriteFolder(olkFolder As Outlook.Folder)
Dim olkPane As Object, _
olkModule As Object, _
olkGroup As Object
Set olkPane = Outlook.Application.ActiveExplorer.NavigationPane
Set olkModule = olkPane.Modules.GetNavigationModule(olModuleMail)
Set olkGroup = olkModule.NavigationGroups.GetDefaultNavigationGroup(olFavoriteFoldersGroup)
olkGroup.NavigationFolders.Add olkFolder
Set olkPane = Nothing
Set olkModule = Nothing
Set olkGroup = Nothing
End Sub






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Sorry ;-(

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
'Define some constants'
Const olMailModule = 158
Const olFavoriteFoldersGroup = 4
'Create some variables'
Dim olkApp, olkSes, olkPane, olkModule, olkGroup, olkFolder
'Connect to Outlook'
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
olkSes.Logon "Outlook"
'Get the Favorites group'
Set olkPane = olkApp.ActiveExplorer.NavigationPane
Set olkModule = olkPane.Modules.GetNavigationModule(olModuleMail)
Set olkGroup = olkModule.NavigationGroups.GetDefaultNavigationGroup(olFavoriteFoldersGroup)
'Get the folder to add'
Set olkFolder = OpenOutlookFolder("Projects\Domain Consolidation") '<- change the folder path here'
'Add the folder to favorites'
olkGroup.NavigationFolders.Add olkFolder
'Clean-up'
Set olkPane = Nothing
Set olkModule = Nothing
Set olkGroup = Nothing
olkSes.Logoff
Set olkSes = Nothing
Set olkApp = Nothing
WScript.Quit
Function IsNothing(obj)
If TypeName(obj) = "Nothing" Then
IsNothing = True
Else
IsNothing = False
End If
End Function
Function OpenOutlookFolder(strFolderPath)
Dim arrFolders, varFolder, olkMyFolder
Set OpenOutlookFolder = Nothing
Set olkMyFolder = Nothing
On Error Resume Next
If strFolderPath = "" Then
Set OpenOutlookFolder = Nothing
Else
Do While Left(strFolderPath, 1) = "\"
strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
Loop
arrFolders = Split(strFolderPath, "\")
For Each varFolder In arrFolders
If IsNothing(olkMyFolder) Then
Set olkMyFolder = olkSes.Folders(varFolder)
Else
Set olkMyFolder = olkMyFolder.Folders(varFolder)
End If
Next
Set OpenOutlookFolder = olkMyFolder
End If
On Error Goto 0
End Function
+ Mailbox - Doe, John
  + Inbox
   - Folder A
+ Public Folders
  + All Public Folders
   - Folder B
The path to Folder A is
  Mailbox - Doe, John\Inbox\Folder A
The path to Folder B is
  Public Folders\All Public Folders\Folder B
Line 19 must contain a valid folder path.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I was able to modify and use this to add CRM favories to about 100 users, you rock!!
Very nicely marked and simple to use!
Cheers.
I need to show public folder calender to mail favorite  folder.  Is there any way to do it via login script or any policy.
 I hope to listen from your end.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Outlook
--
Questions
--
Followers
Top Experts
Microsoft Outlook is a personal information manager from Microsoft, available as a part of the Microsoft Office suite. Although often used mainly as an email application, it also includes a calendar, task manager, contact manager, note-taker, journal, and web browser.