This VBScript must be run as the logged on user. It will output all your Outlook calendar appointments to a CSV file for importing into Microsoft Excel.
I needed a way to report on what calendar appointments our users had to see whether they have more than one entry for a bank holiday.
Option Explicit
Const olFolderCalendar = 9
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim WshShell, WSHFileSystem, objOutlook, objNamespace, objCalendar, oReport
Set WshShell = CreateObject("WScript.Shell")
Set WSHFileSystem = CreateObject("Scripting.FileSystemObject")
Set oReport = WSHFileSystem.CreateTextFile("C:\Support\CalendarAppointments.csv", ForWriting, True)
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objCalendar = objNamespace.GetDefaultFolder(olFolderCalendar)
ProcessCalendar(objCalendar)
Sub ProcessCalendar(objCalendar)
Dim colItems, colItems2, itm
Set colItems = objCalendar.Items
Set colItems2 = colItems.Restrict("[Start] > '01/1/2011' And [Start] < '12/31/2012'")
For Each itm In colItems2
oReport.WriteLine itm.Subject & "," & itm.Start
'wscript.Echo itm.Subject & "," & itm.Start
Next
End Sub
oReport.Close
No comments:
Post a Comment