• Facebook
  • RSS Feed
  • Instagram
  • LinkedIn
  • Twitter
Nov 232009
 

A small script that I needed in order to test Calendar archiving.

To use the script open Outlook as a test user, and run the script.  It will create 500 test appointments lasting 1 hour over the last 20 days.

'on error resume next
set objOutlook=createobject("Outlook.Application")
set MyNameSpace=ObjOutlook.GetNamespace("MAPI")
set MyCalendar = MyNamespace.getdefaultfolder(9)

maxDays=20
minDays=1

maxHour = 23
MinHour = 1

maxMin = 59
MinMin = 0

wscript.echo "Count of items in calendar : " & mycalendar.items.count
for i = 1 to 500

	' Decide on number of days back to do the appointment
	NumDays = (Int((maxDays-minDays+1)*Rnd+minDays))
	vDay= (DatePart("d",Now()-NumDays))
	vMonth =  (DatePart("m",Now()-NumDays))
	vYear =  (DatePart("yyyy",Now()-NumDays))

	NumHour = (Int((maxHour-MinHour+1)*Rnd+MinHour))
	NumMin = (Int((maxMin-MinMin+1)*Rnd+MinMin))
	StartDate = cdate(vday & "/" & vmonth & "/" & vyear & " " & NumHour & ":" & NumMin)

	wscript.echo i & " is loop count, and Start Date : " & startdate

	With MyCalendar.Items.Add(1)
		.AllDayEvent = False
		.Subject = "test appointment " & i
		.Body = "Something goes here"
		.Start = StartDate
		.Duration = 60
		.ReminderSet = False
		.Save
	End With

next

wscript.echo "Count of items in calendar : " & mycalendar.items.count
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)