Lets Automate It

from Josh Rickard

Script Adding Exchange Resource Accounts to Your Outlook

2018-08-07 Josh Rickard

I work for a large public University and we have many Resource Accounts.  We needed a way to move from Public Folders but we wanted it to be seemless as possible.  To do this, I created this VBS script that allows anyone to add Resource Accounts to their Outlook 2013/2010 calendar as a shared calendar.  The user in question will have to run this script while Outlook is open and it will pull the Resource Account (add the Resource Account name in the RESOURCEACCOUNTNAME variable below) from the GAL and add it to the users calendar.  I hope this helps anyone interested in doing the same.

[code ]

‘************************************************************************** ’ Script Name: ADDCALENDAR.vbs ’ Version: 1.0 ’ Author: Josh Rickard ‘Last Updated: 4.Nov.2013 ’ Purpose: This program is used to add Room Resource Calendars to ’ someones Microsoft Office 2013 Shared Calendars group. ’ Outlook 2013 has to be open for this script to continue. ’ This script was originally created for the Trulaske ’ University of REDACTED Technology Services Department. ’ Legal: Script provided "AS IS" without warranties or guarantees ’ of any kind. USE AT YOUR OWN RISK. Public domain. ‘************************************************************************** Dim objApp Dim objNS Dim objFolder Dim strName(3) Dim objDummy Dim objRecip Dim calendar strName(0) = "RESOURCEACCOUNTNAME" strName(1) = "RESOURCEACCOUNTNAME" strName(2) = "RESOURCEACCOUNTNAME" strName(3) = "RESOURCEACCOUNTNAME"

Const olMailItem = 0 Const olFolderCalendar = 9

 

’ This section checks to see if Outlook 2013 is open. If it is not ’ It will return "Please Open Outlook and run this program again"

‘Change "Outlook.Application.15" to "Outlook.Application.14" for Outlook 2010 On Error Resume Next Dim Outlook: Set Outlook = GetObject(, "Outlook.Application.15")

If Err.Number = 0 Then MsgBox "This program will add Room Calendars to your mailbox." Else MsgBox "Please Open Outlook and run this program again." Err.Clear End If

  ’ For Each Next Loop while adds each calendar from strName(array) to the users Shared Calendars

For Each calendar In strName

Set objApp = CreateObject("Outlook.Application.15") Set objNS = objApp.GetNamespace("MAPI") Set objFolder = Nothing

Set objDummy = objApp.CreateItem(olMailItem) Set objRecip = objDummy.Recipients.Add(calendar) objRecip.Resolve If objRecip.Resolved = True Then On Error Resume Next Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar) On Error GoTo 0 Else MsgBox "Could not find ", , _ "User not found" End If

Next

Set GetOtherUserCalendar = objFolder Set objApp = Nothing Set objNS = Nothing Set objFolder = Nothing

[/code ]