Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Forms / July 2004

Tip: Looking for answers? Try searching our database.

Outlook Reccurring Appointments

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Billy - 07 Jul 2004 19:21 GMT
Hi all.

I am writiing a simple application that grabs any appointments and then pages me about 15 minutes before my appointment. (i'm to cheap to buy a PDA) I have everything I need except working code that get's the proper appointments for the day.

I am trying to user VB.Net and have seen ALL of the examples on MSDN but I am still having problems.

Every 15 minutes I want to check the appointments, but when I check them and apply a Restrict on the items it returns 2147483647 items. I'm assuming that's all the days that are available in Outlook.......not really what I am looking for. It seems that my Restrict is not working properly. I have moved it around into different areas and tried the Find method too.

I am using Outlook 2002 and VB.Net to try and do this.

Here is my code. I've tried way too many ideas to give up but alot frustrated. Any assistance would be greatly appreciated.

       Dim oAppt As Outlook.AppointmentItem
       Dim sSearch As String
       Dim oNS As Outlook.NameSpace
       Dim oApp As Outlook.Application
       Dim oCalendar As Outlook.MAPIFolder
       Dim oItems As Outlook.Items
       Dim oRestrictedItems As Outlook.Items
       Dim AlertTime As Date
       Dim i As Integer

       'TODO change the 15 minutes to a parameter in the form
       'AlertTime = Format(DateAdd("n", 15, Now), "hh:mm:ss")

       ' Create Outlook application.
       oApp = New Outlook.Application

       ' Get NameSpace and Logon.
       oNS = oApp.GetNamespace("mapi")
       oNS.Logon("Profile", "Password", False, True) ' TODO:

       ' Get Appointments collection from the Calendar folder.
       oCalendar = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)

       oItems = oCalendar.Items

       ' Use Find method
       sSearch = "[Start] >= '07/06/2004 12:01 AM' and [Start] <= '07/06/2004 11:59 PM'"
       Console.WriteLine(sSearch)

       oItems = oItems.Restrict(sSearch)
       oItems.Sort("[Start]")
       oItems.IncludeRecurrences = True

       For i = 1 To oItems.Count

       oAppt = oItems(i)

           'If AlertTime >= CDate(Format(oAppt.Start, "hh:mm:ss")) And AlertTime < oAppt.End Then
           Console.WriteLine("The following apppoitment is found:")

           Console.WriteLine(oAppt.Subject)
           Console.WriteLine(oAppt.Start)
           Console.WriteLine(oAppt.Duration)

       Next

       ' Log off.
       oNS.Logoff()

       ' Clean up.
       oApp = Nothing
       oNS = Nothing
       oItems = Nothing
       oAppt = Nothing
Ken Slovak - [MVP - Outlook] - 07 Jul 2004 21:57 GMT
Open ended recurring appointments (no limit to number or ending date) will
return that number you see. That's the way it works. In cases like that you
are best off not using IncludeRecurrences and getting the master appointment
and from there figuring out what is the most current one in the series using
the RecurrencePattern.

Take a look at the list of Outlook development KB articles and the articles
on .NET development for Outlook from the Resources page at www.microeye.com.
There are a number of KB's that refer to handling recurring appointments and
the VSNet stuff is the best set of references for .NET development for
Outlook.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Hi all.
>
> I am writiing a simple application that grabs any appointments and then pages me about 15 minutes before my appointment. (i'm to cheap to buy a PDA)
I have everything I need except working code that get's the proper
appointments for the day.

> I am trying to user VB.Net and have seen ALL of the examples on MSDN but I am still having problems.
>
> Every 15 minutes I want to check the appointments, but when I check them and apply a Restrict on the items it returns 2147483647 items. I'm assuming
that's all the days that are available in Outlook.......not really what I am
looking for. It seems that my Restrict is not working properly. I have moved
it around into different areas and tried the Find method too.

> I am using Outlook 2002 and VB.Net to try and do this.
>
[quoted text clipped - 54 lines]
>         oItems = Nothing
>         oAppt = Nothing
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.