-
May 31st, 2002, 09:26 AM
#1
Finding current appointment in Outlook
I want my VB app to check what a particular person is doing at a particular time by looking in their Outlook calendar. I can get the appointments out, but there might be 100s, and some might be recurring, so it is a real drag to do this myself. Is there any easier way to pick out any appointments which coincide with a certain date and time?
Thanks
Aidan
-
May 31st, 2002, 09:40 AM
#2
Try this
VB Code:
Dim myOlApp As New Outlook.Application
Dim myAppt As AppointmentItem
Dim myNS As NameSpace
Dim myAppts As Items
Dim strTheDay As String
Dim strToday As String
Dim strMsg As String
Dim strEndDay As String
Dim rstData As Recordset
Set rstData = gdbs.openrecordset("Data")
strTheDay = Format(MaskEdBox1.Text, "dd/mm/yyyy")
strEndDay = Format(MaskEdBox2.Text, "dd/mm/yyyy")
'specify the range
strToday = "[Start] >= '" & strTheDay & _
"' and [Start] < '" & strEndDay & " 11:59pm '"
'Get user's appointments from Calendar folder
Set myNS = myOlApp.GetNamespace("MAPI")
Set myAppts = myNS.GetDefaultFolder(olFolderCalendar).Items
'sort the collection (required by IncudeRecurrences).
myAppts.Sort "[Start]"
'Make sure recurring appointments are included
myAppts.IncludeRecurrences = True
'filter the collection to include only the day's appointments.
Set myAppts = myAppts.Restrict(strToday)
'Sort again to put recurring appointments in correct order.
myAppts.Sort "[Start]"
'Loop through collection and get subject, start time, location and Busystatus of each time
Set myAppt = myAppts.GetFirst
Do While TypeName(myAppt) <> "Nothing"
rstData.AddNew
rstData!Subject = myAppt.Subject
rstData!Location = myAppt.Location
rstData!Date = Format(myAppt.start, "dd/mm/yyyy")
rstData!busystatus = myAppt.busystatus
rstData.Update
Set myAppt = myAppts.GetNext
Loop
Set myOlApp = Nothing
Set myAppt = Nothing
Set myNS = Nothing
Set myAppts = Nothing
rstData.Close
-
May 31st, 2002, 10:49 AM
#3
That looks perfect - thanks very much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|