Jump to content

Recommended Posts

Posted

Hi,

 

Does anyone know of any script I can use that will add a public calendar to favourites. Like you would do manually in the attached.

 

Thanks

Add to favourites.png

  • 2 weeks later...
Posted

I have one that should do mate.

 

Will post when I get back. It waits for outlook to be launched and then adds public folder favourites to the public folder favourites and then add these to the main favourites. You could get it to do just the last but. Its vbs.

 

Tim

Posted

Sorry for delay..

 

We have four public folders that staff wanted not only in their public folder favourites but also in the main top favourites.

 

In this script they are:

Head's Notices

Weekly Tutor Focus

Daily Bulletin

Rewards & Sanctions

 

But im sure you could change it to your calender and strip the others out.

This script is for 2010 and 2013 as it needs the users email address in the public folder address.

 

This first script waits for outlook to open before calling the script that add the favourites.

I left the first script link enabled for a few weeks until everyone had the favourites stored and then link disabled it.

 

Outlook_Watcher_Script.vbs

 

Set objShell = CreateObject("Wscript.Shell")

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colMonitoredProcesses = objWMIService. _        
   ExecNotificationQuery("Select * from __InstanceCreationEvent " _ 
       & " Within 1 Where TargetInstance ISA 'Win32_Process' AND " & _
           "TargetInstance.Name = 'Outlook.exe'")

Do While True
   Set objProcess = colMonitoredProcesses.NextEvent
   objShell.Run "\\server\netlogon\scripts\Set_PublicFolders_2010.vbs" 
Loop

 

 

 

2010/2013 - Set_PublicFolders_2010.vbs

 

'Function to get email address"
Function GetAddress()

On Error Resume Next
   Dim objSysInfo, objUser
   Set objSysInfo = CreateObject("ADSystemInfo")
   Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
   GetAddress = objUser.EmailAddress 
End Function

wscript.sleep(4000) '4 second

Const olPublicFoldersAllPublicFolders = 18
Const olFavoriteFoldersGroup = 4

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"

  On Error Resume Next
'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 - " & GetAddress() & "\All Public Folders\Head's Notices")
olkFolder.AddToPFFavorites
Set olkFolder = OpenOutlookFolder("\Public Folders - " & GetAddress() & "\All Public Folders\Weekly Tutor Focus")
olkFolder.AddToPFFavorites
Set olkFolder = OpenOutlookFolder("\Public Folders - " & GetAddress() & "\All Public Folders\Daily Bulletin")
olkFolder.AddToPFFavorites
Set olkFolder = OpenOutlookFolder("\Public Folders - " & GetAddress() & "\All Public Folders\Rewards & Sanctions")
olkFolder.AddToPFFavorites
Set olkFolder = OpenOutlookFolder("\Public Folders - " & GetAddress() & "\All Public Folders\Urgent Staff Notices")
olkFolder.AddToPFFavorites

'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 - " & GetAddress() & "\Favorites\Head's Notices")
AddFavoriteFolder olkFolder
Set olkFolder = OpenOutlookFolder("\Public Folders - " & GetAddress() & "\Favorites\Weekly Tutor Focus")
AddFavoriteFolder olkFolder
Set olkFolder = OpenOutlookFolder("\Public Folders - " & GetAddress() & "\Favorites\Daily Bulletin")
AddFavoriteFolder olkFolder
Set olkFolder = OpenOutlookFolder("\Public Folders - " & GetAddress() & "\Favorites\Rewards & Sanctions")
AddFavoriteFolder olkFolder
Set olkFolder = OpenOutlookFolder("\Public Folders - " & GetAddress() & "\Favorites\Urgent Staff Notices")
AddFavoriteFolder olkFolder

olkSes.Logoff
Set olkApp = Nothing
Set olkSes = Nothing
Set olkFolder = Nothing
WScript.Quit

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
   Else
       Do While Left(strFolderPath, 1) = "\"
           strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
       Loop
       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
       Next
   End If
   On Error GoTo 0
End Function

  • Thanks 1
  • 1 month later...
Posted

Burge,

 

 

I was looking at the script and I think what FN-GM wants is not to add it to the folder mail favorites but to the calendar favorites. right now what happens is it adds it to the favorites but it doesn't display the content until someone goes out and actually clicks on the calendar to display. I have been looking to do that as well. I did get the code to work as far as bringing in the calendars but then to display them it doesn't work out. Another note also I have only gotten it to work with Outlook 2010. The code won't work with 2013. Is there a difference.

 

 

Thanks,

Posted
This is similar to what i am trying to accomplish. I can get it to show in the public folder favorites and therefore in the "others" category under calendars but i would like to see if I can have it selected as well. It works great in Outlook 2010 but can't seem to get it working in Outlook 2013. Is there anything different between the two. I know others have said it works in either. I just can't see to get it working. Add public Calendar to Calendar list - W&J ITS HelpDesk - Washington & Jefferson College Confluence
Posted

I think I figured it out. It seems to only work with 32Bit. It is not working on 64bit version. Also if these changes are made do they carry over to any other outlook client I might open or via web outlook. I am testing but it doesn't seem to be there. Just wondering if this is possible. That the changes are stored on exchange and can carry over.

 

 

 

thanks

Posted

It seems that it works fine with Outlook 2013 32Bit version and not 64Bit version at this point, but we ran into another snafu. I guess the bigger question needs to be answered.

 

Overall scenario: share with all employees a calendar of events for the entire school. Currently we push the calendar or I should say events via script but this puts every school event on everyone's personal calendar. Since this is done only once a year we miss everyone that gets hired mid-year. Also If there is a mistake we then have to resend stuff out. We would prefer to still push a calendar out but in the manner mentioned earlier in the topic. Can this be possible but at the same time allow the end user to see it via outlook or web outlook. They can always delete it if they do not choose to use it but at least from our stand point we send it out.

 

Any ideas

  • 4 weeks later...
Posted

@burgemaster it seems to work well for any items in a folder but i can't get it to work where there is a calendar in a folder. Any ideas please? Maybe there is a way to target the actual calendar?

 

Thanks

Posted

Think i have done it change the path to something like

 

Set olkFolder = OpenOutlookFolder("\Public Folders - " & GetAddress() & "\All Public Folders\Head's Notices\Calendar Name")

Posted
Hmm having issue with the watcher script. Its telling me the path to the Set_PublicFolders_2010.vbs is invalid. It isnt though.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...