A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to create recurring appointment exceptions? VSTO 2k8



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 6th 08, 12:12 AM posted to microsoft.public.outlook.program_addins
mikeo
external usenet poster
 
Posts: 7
Default How to create recurring appointment exceptions? VSTO 2k8

I am writing an Outlook 2007 Add-in using VSTO 2008 (VB .NET). I want to
allow the user to add an appointment that is associated with an existing
recurring appointment. The catch is that the given date may not fit the
recurrence pattern. For example, if the user has an Inspector window open
with an occurence of an "every Thursday" appointment, he may choose to add a
Monday. I know the object model supports it because I can do it manually by
selecting a recurrance and changing the start date.

I have been able to programmatically add a new "non-exception" meeting by
calling AppointmentItem.GetRecurrencePattern and incrementing
recurPattern.Occurrences. I can also refer to the new appointment via
recurPattern.GetOccurence(date). However, I haven't found a way to update
the appointment start date and create an exception. Here is some of the code
I've been trying:

' Add an appointment for this date
Public Sub AddDate(ByVal dt As Date)
Dim inspector As Outlook._Inspector = Nothing
Dim apptItem As Outlook.AppointmentItem = Nothing
Dim recurPattern As Outlook.RecurrencePattern = Nothing
Dim newDate As Date
Dim newApptItem As Outlook.AppointmentItem = Nothing
Dim origEndDate As Date

Try
inspector = OutlookApp.ActiveInspector
Catch
End Try

If inspector IsNot Nothing Then
apptItem = inspector.CurrentItem
If apptItem.IsRecurring Then

Try
' get the recurrence pattern
recurPattern = apptItem.GetRecurrencePattern

' get a new meeting by incrementing the occurrences
recurPattern.Occurrences += 1

' get the newly-created appointment item
newDate = New Date(recurPattern.PatternEndDate.Year, _
recurPattern.PatternEndDate.Month, _
recurPattern.PatternEndDate.Day, _
recurPattern.StartTime.Hour, _
recurPattern.StartTime.Minute, _
recurPattern.StartTime.Second)
newApptItem = recurPattern.GetOccurrence(newDate)

' set the start date of the new meeting to the desired
date
newDate = New Date(dt.Year, dt.Month, dt.Day, _
recurPattern.StartTime.Hour, _
recurPattern.StartTime.Minute, _
recurPattern.StartTime.Second)

' this update gets lost if newDate is out of the
recurrence pattern ....
newApptItem.Start = newDate

Catch
End Try
Else
' need to make it recurring ...
End If
End If

If inspector IsNot Nothing Then Marshal.ReleaseComObject(inspector)
If apptItem IsNot Nothing Then Marshal.ReleaseComObject(apptItem)
If recurPattern IsNot Nothing Then
Marshal.ReleaseComObject(recurPattern)
If newApptItem IsNot Nothing Then
Marshal.ReleaseComObject(newApptItem)
End Sub


Is there a better approach to add an "exception" appointment to an existing
recurrence pattern? Or, to put it another way, is there a way in VSTO to set
the appointment conversationIndex to associate it with other appointments?
Any suggestions are greatly appreciated.

Thanks,
mikeo


Ads
  #2  
Old May 6th 08, 02:24 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to create recurring appointment exceptions? VSTO 2k8

Changing the date of any existing instance of a recurring series will create
an exception, are you saving the item after applying the change to the start
date?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"mikeo" wrote in message
...
I am writing an Outlook 2007 Add-in using VSTO 2008 (VB .NET). I want to
allow the user to add an appointment that is associated with an existing
recurring appointment. The catch is that the given date may not fit the
recurrence pattern. For example, if the user has an Inspector window open
with an occurence of an "every Thursday" appointment, he may choose to add
a
Monday. I know the object model supports it because I can do it manually
by
selecting a recurrance and changing the start date.

I have been able to programmatically add a new "non-exception" meeting by
calling AppointmentItem.GetRecurrencePattern and incrementing
recurPattern.Occurrences. I can also refer to the new appointment via
recurPattern.GetOccurence(date). However, I haven't found a way to update
the appointment start date and create an exception. Here is some of the
code
I've been trying:

' Add an appointment for this date
Public Sub AddDate(ByVal dt As Date)
Dim inspector As Outlook._Inspector = Nothing
Dim apptItem As Outlook.AppointmentItem = Nothing
Dim recurPattern As Outlook.RecurrencePattern = Nothing
Dim newDate As Date
Dim newApptItem As Outlook.AppointmentItem = Nothing
Dim origEndDate As Date

Try
inspector = OutlookApp.ActiveInspector
Catch
End Try

If inspector IsNot Nothing Then
apptItem = inspector.CurrentItem
If apptItem.IsRecurring Then

Try
' get the recurrence pattern
recurPattern = apptItem.GetRecurrencePattern

' get a new meeting by incrementing the occurrences
recurPattern.Occurrences += 1

' get the newly-created appointment item
newDate = New Date(recurPattern.PatternEndDate.Year, _
recurPattern.PatternEndDate.Month, _
recurPattern.PatternEndDate.Day, _
recurPattern.StartTime.Hour, _
recurPattern.StartTime.Minute, _
recurPattern.StartTime.Second)
newApptItem = recurPattern.GetOccurrence(newDate)

' set the start date of the new meeting to the desired
date
newDate = New Date(dt.Year, dt.Month, dt.Day, _
recurPattern.StartTime.Hour, _
recurPattern.StartTime.Minute, _
recurPattern.StartTime.Second)

' this update gets lost if newDate is out of the
recurrence pattern ....
newApptItem.Start = newDate

Catch
End Try
Else
' need to make it recurring ...
End If
End If

If inspector IsNot Nothing Then Marshal.ReleaseComObject(inspector)
If apptItem IsNot Nothing Then Marshal.ReleaseComObject(apptItem)
If recurPattern IsNot Nothing Then
Marshal.ReleaseComObject(recurPattern)
If newApptItem IsNot Nothing Then
Marshal.ReleaseComObject(newApptItem)
End Sub


Is there a better approach to add an "exception" appointment to an
existing
recurrence pattern? Or, to put it another way, is there a way in VSTO to
set
the appointment conversationIndex to associate it with other appointments?
Any suggestions are greatly appreciated.

Thanks,
mikeo



  #3  
Old May 6th 08, 03:57 PM posted to microsoft.public.outlook.program_addins
mikeo
external usenet poster
 
Posts: 7
Default How to create recurring appointment exceptions? VSTO 2k8

Hi Ken,

Thanks for your quick reply ...

You raise a good point - when I try to save the item (via
AppointmentItem.Save) I get the following exception (AccessViolationException
is caught by my "catch" statement) and the inspector window closes:

"Attempted to read or write protected memory. This is often an indication
that other memory is corrupt."

I find that the "non-exception" item that created, but the start date wasn't
updated. I assume that I'm not allowed in VSTO to explicitly save this item
that Outlook created via COM when I add a recurrence ... or could it be
related to releasing/not releasing COM objects appropriately?

Thanks a lot for your help,
Mike

"Ken Slovak - [MVP - Outlook]" wrote:

Changing the date of any existing instance of a recurring series will create
an exception, are you saving the item after applying the change to the start
date?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"mikeo" wrote in message
...
I am writing an Outlook 2007 Add-in using VSTO 2008 (VB .NET). I want to
allow the user to add an appointment that is associated with an existing
recurring appointment. The catch is that the given date may not fit the
recurrence pattern. For example, if the user has an Inspector window open
with an occurence of an "every Thursday" appointment, he may choose to add
a
Monday. I know the object model supports it because I can do it manually
by
selecting a recurrance and changing the start date.

I have been able to programmatically add a new "non-exception" meeting by
calling AppointmentItem.GetRecurrencePattern and incrementing
recurPattern.Occurrences. I can also refer to the new appointment via
recurPattern.GetOccurence(date). However, I haven't found a way to update
the appointment start date and create an exception. Here is some of the
code
I've been trying:

' Add an appointment for this date
Public Sub AddDate(ByVal dt As Date)
Dim inspector As Outlook._Inspector = Nothing
Dim apptItem As Outlook.AppointmentItem = Nothing
Dim recurPattern As Outlook.RecurrencePattern = Nothing
Dim newDate As Date
Dim newApptItem As Outlook.AppointmentItem = Nothing
Dim origEndDate As Date

Try
inspector = OutlookApp.ActiveInspector
Catch
End Try

If inspector IsNot Nothing Then
apptItem = inspector.CurrentItem
If apptItem.IsRecurring Then

Try
' get the recurrence pattern
recurPattern = apptItem.GetRecurrencePattern

' get a new meeting by incrementing the occurrences
recurPattern.Occurrences += 1

' get the newly-created appointment item
newDate = New Date(recurPattern.PatternEndDate.Year, _
recurPattern.PatternEndDate.Month, _
recurPattern.PatternEndDate.Day, _
recurPattern.StartTime.Hour, _
recurPattern.StartTime.Minute, _
recurPattern.StartTime.Second)
newApptItem = recurPattern.GetOccurrence(newDate)

' set the start date of the new meeting to the desired
date
newDate = New Date(dt.Year, dt.Month, dt.Day, _
recurPattern.StartTime.Hour, _
recurPattern.StartTime.Minute, _
recurPattern.StartTime.Second)

' this update gets lost if newDate is out of the
recurrence pattern ....
newApptItem.Start = newDate

Catch
End Try
Else
' need to make it recurring ...
End If
End If

If inspector IsNot Nothing Then Marshal.ReleaseComObject(inspector)
If apptItem IsNot Nothing Then Marshal.ReleaseComObject(apptItem)
If recurPattern IsNot Nothing Then
Marshal.ReleaseComObject(recurPattern)
If newApptItem IsNot Nothing Then
Marshal.ReleaseComObject(newApptItem)
End Sub


Is there a better approach to add an "exception" appointment to an
existing
recurrence pattern? Or, to put it another way, is there a way in VSTO to
set
the appointment conversationIndex to associate it with other appointments?
Any suggestions are greatly appreciated.

Thanks,
mikeo




  #4  
Old May 7th 08, 12:01 AM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to create recurring appointment exceptions? VSTO 2k8

I don't see VSTO preventing any saves of items. It's mostly a shim loader
and wrapper for unhandled exceptions and for the IDTExtensibility
interfaces.

I think the problem is your algorithm. If you extend the number of
occurrences the new item goes at the end of the series. You are trying to
reschedule the new appointment to some other date, triggering the Outlook
error: "cannot reschedule an occurrence if it skips over a later occurrence
of the same appointment". That's the problem.

What you'd have to do is to change the occurrence just after the new desired
date to that date, change the following appointment to the date of the
occurrence you just changed, repeat for every occurence in the series to
avoid that error. It would be hell to manage and code, if it would even work
at all.

And if it did work you'd end up with the entire series being exceptions.

As I said, this has nothing to do with VSTO or Outlook version. It's a
limitation of the implementation of RecurrencePattern and its binary blob.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"mikeo" wrote in message
...
Hi Ken,

Thanks for your quick reply ...

You raise a good point - when I try to save the item (via
AppointmentItem.Save) I get the following exception
(AccessViolationException
is caught by my "catch" statement) and the inspector window closes:

"Attempted to read or write protected memory. This is often an indication
that other memory is corrupt."

I find that the "non-exception" item that created, but the start date
wasn't
updated. I assume that I'm not allowed in VSTO to explicitly save this
item
that Outlook created via COM when I add a recurrence ... or could it be
related to releasing/not releasing COM objects appropriately?

Thanks a lot for your help,
Mike


  #5  
Old May 9th 08, 10:35 PM posted to microsoft.public.outlook.program_addins
mikeo
external usenet poster
 
Posts: 7
Default How to create recurring appointment exceptions? VSTO 2k8

Hi Ken,

Thanks again for your insightful feedback.

I'm not convinced that this is the specific issue. Since the addition of
exception items is fundamental to the requirements for my add-in, I'm not
ready to throw in the towel yet ...

I receive the protected memory exception even if the item I'm trying to
create/save remains as the last item in the pattern. For example, the last
recurrence of a weekly recurring meeting is on Friday, May 9th. When my code
increments recurPattern.Occurrences by 1, Outlook creates a new occurence on
Friday, May 16th. When I programmatically try to update the Start date of
this new item to Thu May 15, I get the error. Note that Outlook lets me do
this manually (i.e. increment Occurrences by 1, save, open the new last
recurrence, update date, save.

Any other theories as to what is going wrong here? Debugging suggestions?

Thanks,
mikeo



"Ken Slovak - [MVP - Outlook]" wrote:

I don't see VSTO preventing any saves of items. It's mostly a shim loader
and wrapper for unhandled exceptions and for the IDTExtensibility
interfaces.

I think the problem is your algorithm. If you extend the number of
occurrences the new item goes at the end of the series. You are trying to
reschedule the new appointment to some other date, triggering the Outlook
error: "cannot reschedule an occurrence if it skips over a later occurrence
of the same appointment". That's the problem.

What you'd have to do is to change the occurrence just after the new desired
date to that date, change the following appointment to the date of the
occurrence you just changed, repeat for every occurence in the series to
avoid that error. It would be hell to manage and code, if it would even work
at all.

And if it did work you'd end up with the entire series being exceptions.

As I said, this has nothing to do with VSTO or Outlook version. It's a
limitation of the implementation of RecurrencePattern and its binary blob.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"mikeo" wrote in message
...
Hi Ken,

Thanks for your quick reply ...

You raise a good point - when I try to save the item (via
AppointmentItem.Save) I get the following exception
(AccessViolationException
is caught by my "catch" statement) and the inspector window closes:

"Attempted to read or write protected memory. This is often an indication
that other memory is corrupt."

I find that the "non-exception" item that created, but the start date
wasn't
updated. I assume that I'm not allowed in VSTO to explicitly save this
item
that Outlook created via COM when I add a recurrence ... or could it be
related to releasing/not releasing COM objects appropriately?

Thanks a lot for your help,
Mike



  #6  
Old May 12th 08, 02:04 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to create recurring appointment exceptions? VSTO 2k8

No other suggestions, my guess is that Outlook doesn't like your
incrementing Occurrences in code. But that's just a guess.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"mikeo" wrote in message
...
Hi Ken,

Thanks again for your insightful feedback.

I'm not convinced that this is the specific issue. Since the addition of
exception items is fundamental to the requirements for my add-in, I'm not
ready to throw in the towel yet ...

I receive the protected memory exception even if the item I'm trying to
create/save remains as the last item in the pattern. For example, the
last
recurrence of a weekly recurring meeting is on Friday, May 9th. When my
code
increments recurPattern.Occurrences by 1, Outlook creates a new occurence
on
Friday, May 16th. When I programmatically try to update the Start date of
this new item to Thu May 15, I get the error. Note that Outlook lets me
do
this manually (i.e. increment Occurrences by 1, save, open the new last
recurrence, update date, save.

Any other theories as to what is going wrong here? Debugging suggestions?

Thanks,
mikeo


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Recurring appointments with exceptions Karin Outlook - Calandaring 1 January 15th 07 12:03 PM
Exceptions to recurring items Dave Collier Outlook - Calandaring 0 October 19th 06 11:05 PM
Finding Recurring Items with Exceptions Tadwick Outlook and VBA 1 September 15th 06 05:29 AM
How do I create a recurring appointment without assigning a time? old irish pig Outlook - Calandaring 2 August 1st 06 04:38 PM
How to Create Exceptions to Recurring Appointment Sabrina Outlook - General Queries 1 January 11th 06 02:10 PM


All times are GMT +1. The time now is 09:29 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.