How to automate Public folder calender to show in Favorite Folder of mail.

Posted on 2011-10-27
Last Modified: 2012-05-12

How to automate the process to show my public folder calender in Mail Favorite folder?

I wanted to do it either by login script or by group policy.

I am using Microsoft Exchange server 2007 with Windows Server 2008 R2 and Domain controller running Windows Server 2003 R2.  

All workstation system have either Outlook 2010 or Outlook 2007.

While searching on this I found the script below, but by this script (already modified the path) I am just able to make public folder calender to show in public folder favorite but not in mail favorite folder.

 Const olPublicFoldersAllPublicFolders = 18
Dim olkApp, olkSes, olkFolder
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNameSpace("MAPI")
'Change the profile name on the next line'
olkSes.Logon "Outlook"
'Change the folder name on the next line.  Repeat the next two lines for each folder you want to add.'
Set olkFolder = olkSes.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("Public calender").Folders("p cal")
'Change the folder name on the next line.  Repeat the next two lines for each folder you want to add.'
Set olkFolder = OpenOutlookFolder("Public Folders\Favorites\P cal")
AddFavoriteFolder olkFolder
Set olkApp = Nothing
Set olkSes = Nothing
Set olkFolder = Nothing
Sub AddFavoriteFolder(olkFolder)
    ' Purpose: Add a folder to Favorite Folders.'
    ' Written: 5/2/2009'
    ' Author:  BlueDevilFan'
    ' Outlook: 2007'
    Const olModuleMail = 0
    Const olFavoriteFoldersGroup = 4
        Dim olkPane, olkModule, olkGroup
    Set olkPane = olkApp.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
Function OpenOutlookFolder(strFolderPath)
    ' Purpose: Opens an Outlook folder from a folder path.'
    ' Written: 4/24/2009'
    ' Author:  BlueDevilFan'
    ' Outlook: All versions'
    Dim arrFolders, varFolder, bolBeyondRoot
    On Error Resume Next
    If strFolderPath = "" Then
        Set OpenOutlookFolder = Nothing
        Do While Left(strFolderPath, 1) = "\"
            strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
        arrFolders = Split(strFolderPath, "\")
        For Each varFolder In arrFolders
            Select Case bolBeyondRoot
                Case False
                    Set OpenOutlookFolder = olkSes.Folders(varFolder)
                    bolBeyondRoot = True
                Case True
                    Set OpenOutlookFolder = OpenOutlookFolder.Folders(varFolder)
            End Select
            If Err.Number <> 0 Then
                Set OpenOutlookFolder = Nothing
                Exit For
            End If
    End If
    On Error GoTo 0
End Function

I wanted my this folder
     Public Calender
TO show here
 I want "P cal" here
Question by:OTSSolutions
    LVL 11

    Expert Comment


    Author Comment

    Thanks for Reply

    Sorry but that past was done by me for the same issue.

    Author Comment

    I am still facing the same issue.  I think I am missing a little somewhere in the VB script. Any one know VB script of outlook please help me in making this script working.
    LVL 76

    Accepted Solution

    Hi, OTSSolutions.

    This isn't possible either via a macro or manually.  You can't have a calendar appear in Favorites.  Favorites is strictly for mail folders.  The option to add a folder to Favorites is only available if the folder you've right-clicked on is a mail folder.

    Author Comment

    Hi BlueDevilFan,

    Thanks alot for you reply.  can I use the same script to show Public calendar to Public Favorite folder as a login script.
    LVL 76

    Expert Comment

    by:David Lee
    You're welcome.  

    Yes, the script can be integrated into a login script.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
    This video discusses moving either the default database or any database to a new volume.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now