Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Get list of appointments

Keywords:   Outlook calendar

Question:

I need to create a script to write a file from several calender boxes. The result should be a list with all the appointments.

Answer:

Hope this helps get you started

;---------------------------------------------------------------------------
; Outlook_Calendar
;---------------------------------------------------------------------------

;These variables help define a date search filter
StartDateUS = "5/23/1997"
EndDateUS = "5/23/2002"

olPrivate        = 2
olFolderCalendar = 9

objOutlook   = ObjectOpen("Outlook.Application")
objMAPI      = objOutlook.GetNameSpace("MAPI")
objCurrent   = objMAPI.CurrentUser
objName      = objCurrent.Name
;objName      = "Joe Shmoe"

objUser = objMAPI.CreateRecipient(objName)
objUser.Resolve
if objUser.Resolved then
       Message("Resolve","User identified OK")
else
        Message("Resolve","User not resolved")
end if

objCalendar = objMAPI.GetDefaultFolder(olFolderCalendar)
objItems    = objCalendar.Items
;objItems.IncludeRecurrences = @True

;total = objItems.Count
restriction = StrCat('[Start] >= "',StartDateUS,'" And [End] <= "',EndDateUS,'"')
objRestrict = objItems.Restrict(restriction)
objRestrict.Sort("[Start]")

objFirst    = objRestrict.GetFirst
;check if there are any appointments
if objFirst != 0
	ApptSubject = objFirst.Subject
	ApptStart   = objFirst.Start
	ApptEnd     = objFirst.End
	ApptStatus  = objFirst.BusyStatus
	ApptADE     = objFirst.AllDayEvent
	
	if ApptADE == -1 then
	        ADEflag = "All Day Event"
	else
	        ADEflag = ""
	end if
	if objFirst.Sensitivity == olPrivate then ApptSubject = "PRIVATE"
	
	switch ApptStatus
	        case 1
	                BusyStatus = "Tentative  %ADEflag%"
	                break
	        case 2
	                BusyStatus = "Busy  %ADEflag%"
	                break
	        case 3
	                BusyStatus = "Out of Office  %ADEflag%"
	                break
	end switch
	
	output = FileOpen("c:\temp\outlook.txt","WRITE")
	FileWrite(output,StrCat("4 week calendar for ",objName))
	FileWrite(output,StrCat(ApptStart,@tab,ApptEnd,@tab,ApptSubject,@tab,BusyStatus))
	
	for i = 2 to objRestrict.Count
	        objFirst    = objRestrict.GetNext
	        ApptSubject = objFirst.Subject
	        ApptStart   = objFirst.Start
	        ApptEnd     = objFirst.End
	        ApptStatus  = objFirst.BusyStatus
	        ApptADE     = objFirst.AllDayEvent
	
	        if ApptADE == -1 then
	                ADEflag = "All Day Event"
	        else
	                ADEflag = ""
	        end if
	        if objFirst.Sensitivity == olPrivate then ApptSubject = "PRIVATE"
	
	
	        switch ApptStatus
	                case 1
	                        BusyStatus = "Tentative  %ADEflag%"
	                        break
	                case 2
	                        BusyStatus = "Busy  %ADEflag%"
	                        break
	                case 3
	                        BusyStatus = "Out of Office  %ADEflag%"
	                        break
	        end switch
	
	        FileWrite(output,"%ApptStart%  %ApptEnd%  %ApptSubject%  %BusyStatus%")
	next i
Else
  Message("Appointment checker","No Appointments found")
Endif

ObjectClose(objOutlook)
FileClose(output)





Article ID:   W14682
Filename:   Get list of appointments.txt