Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Saving exception item in recurring appointment item fails (http://www.outlookbanter.com/outlook-vba/20344-saving-exception-item-recurring-appointment.html)

Dikbill July 11th 06 02:38 PM

Saving exception item in recurring appointment item fails
 
Hi there,

I have the following problem,

I have a recurring Outlook appointment item, sheduled for every workday
for two weeks, so 10 appointments in total.
Startdate = 11-07-2006 and the end date is 24-07-2006.
No other items are available in Outlook! (Test environment)
Now I change the subject of one of the items in Outlook and save the item.
Outlook changes the recurring symbol on this item to a recurring symbol with
a line thru it so I asume that's the way of Outlook to show it's an
exception item.

Now I have a VB.net program which communicates with Outlook.
The problem is when I save the one item, all items from the recurring set
will be adjusted and not just the one item :-(

All 10 items for the recurring set will have the same body text.
All 10 items do have the same Entry ID value but I can get the items
seperatly, only when I save one item all 10 items are adjusted.
Outlook must have an (internal) ID for the seperate (10) items???

What am I doing wrong?
Is there a way to save just that one exception item???

Thanx a lot,

Dikbill, The Netherlands


I use the following code, written in VB 2005 with Outlook 2003 SP2

Dim ol As Outlook.Application
Dim olns As Outlook.NameSpace
Dim Item As Object
Dim StoreID As String

' Set the application object
ol = New Outlook.Application
' Set the namespace object
olns = ol.GetNamespace("MAPI")
Dim objFolder As Outlook.MAPIFolder

Dim objItems As Object = Nothing
Dim strFilter As Object = Nothing
Dim objTest As Object = Nothing
Dim sPersfoldername As String = ""
Dim objFolders As Object = olns.Folders

For Each objFolder In objFolders 'Just a test to get the public
folder name
sPersfoldername = objFolder.Name
Next

sPersfoldername = sPersfoldername & "\Agenda"
objFolder = GetMAPIFolder(sPersfoldername, ol, olns)
objItems = objFolder.Items
objItems.Sort("[Start]")
objItems.IncludeRecurrences = True 'Set to true so I get all
appointments seperately!!

'When you set the property 'IncludeRecurrences ' to true, you can't
use the objTest.items.count
'because it will return the number 2147483647!!!
'See
http://www.microsoft.com/technet/pro...ty/outapp.mspx
'about this feature!

'Here I filter on date so I wil only have 1 item returned!!
strFilter = "[Start] = " & Quote(DateValue("11-07-2006") & "
23:59") & " And " & _
"[End] " & Quote(DateValue("11-07-2006") & " 0:00")
Dim myAppt As Outlook.AppointmentItem
Dim strMsg As String = ""

objTest = objItems.Restrict(strFilter)
myAppt = objTest.GetFirst
Dim sPrevEntryID As String = ""
Dim iRecurrCount As Integer = 1
' Get the StoreID, which is a property of the folder
StoreID = objFolder.StoreID

'This loop will be entered only one time in this case!
Do While TypeName(myAppt) "Nothing"
strMsg = ""
strMsg = strMsg & vbLf & myAppt.Subject & "Nr:" & iRecurrCount
strMsg = strMsg & " at " & Format(myAppt.Start, "hh:mm") &
vbCrLf
MsgBox(strMsg)
iRecurrCount = iRecurrCount + 1
sPrevEntryID = myAppt.EntryID
Item = olns.GetItemFromID(myAppt.EntryID, StoreID)

'Item.display()
Dim oAgendaItem As Outlook.AppointmentItem = Item
oAgendaItem.Body = "Adjust Body text :-)"
oAgendaItem.Save() 'After this statement all 10 items are
adjusted!!!
myAppt = objTest.GetNext
Loop




Ken Slovak - [MVP - Outlook] July 11th 06 02:50 PM

Saving exception item in recurring appointment item fails
 
If you get an instance of that appointment and use
GetRecurrencePattern.Parent you get to the master appointment in the series.
Using the GetOccurrence method of the RecurrencePattern object gets you a
single occurrence of that series. The Exceptions collection contains all
exceptions.

--
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


"Dikbill" wrote in message
. ..
Hi there,

I have the following problem,

I have a recurring Outlook appointment item, sheduled for every workday
for two weeks, so 10 appointments in total.
Startdate = 11-07-2006 and the end date is 24-07-2006.
No other items are available in Outlook! (Test environment)
Now I change the subject of one of the items in Outlook and save the item.
Outlook changes the recurring symbol on this item to a recurring symbol
with
a line thru it so I asume that's the way of Outlook to show it's an
exception item.

Now I have a VB.net program which communicates with Outlook.
The problem is when I save the one item, all items from the recurring set
will be adjusted and not just the one item :-(

All 10 items for the recurring set will have the same body text.
All 10 items do have the same Entry ID value but I can get the items
seperatly, only when I save one item all 10 items are adjusted.
Outlook must have an (internal) ID for the seperate (10) items???

What am I doing wrong?
Is there a way to save just that one exception item???

Thanx a lot,

Dikbill, The Netherlands


I use the following code, written in VB 2005 with Outlook 2003 SP2

Dim ol As Outlook.Application
Dim olns As Outlook.NameSpace
Dim Item As Object
Dim StoreID As String

' Set the application object
ol = New Outlook.Application
' Set the namespace object
olns = ol.GetNamespace("MAPI")
Dim objFolder As Outlook.MAPIFolder

Dim objItems As Object = Nothing
Dim strFilter As Object = Nothing
Dim objTest As Object = Nothing
Dim sPersfoldername As String = ""
Dim objFolders As Object = olns.Folders

For Each objFolder In objFolders 'Just a test to get the public
folder name
sPersfoldername = objFolder.Name
Next

sPersfoldername = sPersfoldername & "\Agenda"
objFolder = GetMAPIFolder(sPersfoldername, ol, olns)
objItems = objFolder.Items
objItems.Sort("[Start]")
objItems.IncludeRecurrences = True 'Set to true so I get all
appointments seperately!!

'When you set the property 'IncludeRecurrences ' to true, you can't
use the objTest.items.count
'because it will return the number 2147483647!!!
'See
http://www.microsoft.com/technet/pro...ty/outapp.mspx
'about this feature!

'Here I filter on date so I wil only have 1 item returned!!
strFilter = "[Start] = " & Quote(DateValue("11-07-2006") & "
23:59") & " And " & _
"[End] " & Quote(DateValue("11-07-2006") & " 0:00")
Dim myAppt As Outlook.AppointmentItem
Dim strMsg As String = ""

objTest = objItems.Restrict(strFilter)
myAppt = objTest.GetFirst
Dim sPrevEntryID As String = ""
Dim iRecurrCount As Integer = 1
' Get the StoreID, which is a property of the folder
StoreID = objFolder.StoreID

'This loop will be entered only one time in this case!
Do While TypeName(myAppt) "Nothing"
strMsg = ""
strMsg = strMsg & vbLf & myAppt.Subject & "Nr:" & iRecurrCount
strMsg = strMsg & " at " & Format(myAppt.Start, "hh:mm") &
vbCrLf
MsgBox(strMsg)
iRecurrCount = iRecurrCount + 1
sPrevEntryID = myAppt.EntryID
Item = olns.GetItemFromID(myAppt.EntryID, StoreID)

'Item.display()
Dim oAgendaItem As Outlook.AppointmentItem = Item
oAgendaItem.Body = "Adjust Body text :-)"
oAgendaItem.Save() 'After this statement all 10 items are
adjusted!!!
myAppt = objTest.GetNext
Loop





Dikbill July 11th 06 03:59 PM

Saving exception item in recurring appointment item fails
 
Ken,

Thnx a 1000!!
I've used that method and works fine!!

Greetz,

Dikbill, The Netherlands



"Ken Slovak - [MVP - Outlook]" schreef in bericht
...
If you get an instance of that appointment and use
GetRecurrencePattern.Parent you get to the master appointment in the
series. Using the GetOccurrence method of the RecurrencePattern object
gets you a single occurrence of that series. The Exceptions collection
contains all exceptions.

--
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


"Dikbill" wrote in message
. ..
Hi there,

I have the following problem,

I have a recurring Outlook appointment item, sheduled for every workday
for two weeks, so 10 appointments in total.
Startdate = 11-07-2006 and the end date is 24-07-2006.
No other items are available in Outlook! (Test environment)
Now I change the subject of one of the items in Outlook and save the
item.
Outlook changes the recurring symbol on this item to a recurring symbol
with
a line thru it so I asume that's the way of Outlook to show it's an
exception item.

Now I have a VB.net program which communicates with Outlook.
The problem is when I save the one item, all items from the recurring set
will be adjusted and not just the one item :-(

All 10 items for the recurring set will have the same body text.
All 10 items do have the same Entry ID value but I can get the items
seperatly, only when I save one item all 10 items are adjusted.
Outlook must have an (internal) ID for the seperate (10) items???

What am I doing wrong?
Is there a way to save just that one exception item???

Thanx a lot,

Dikbill, The Netherlands


I use the following code, written in VB 2005 with Outlook 2003 SP2

Dim ol As Outlook.Application
Dim olns As Outlook.NameSpace
Dim Item As Object
Dim StoreID As String

' Set the application object
ol = New Outlook.Application
' Set the namespace object
olns = ol.GetNamespace("MAPI")
Dim objFolder As Outlook.MAPIFolder

Dim objItems As Object = Nothing
Dim strFilter As Object = Nothing
Dim objTest As Object = Nothing
Dim sPersfoldername As String = ""
Dim objFolders As Object = olns.Folders

For Each objFolder In objFolders 'Just a test to get the public
folder name
sPersfoldername = objFolder.Name
Next

sPersfoldername = sPersfoldername & "\Agenda"
objFolder = GetMAPIFolder(sPersfoldername, ol, olns)
objItems = objFolder.Items
objItems.Sort("[Start]")
objItems.IncludeRecurrences = True 'Set to true so I get all
appointments seperately!!

'When you set the property 'IncludeRecurrences ' to true, you
can't
use the objTest.items.count
'because it will return the number 2147483647!!!
'See
http://www.microsoft.com/technet/pro...ty/outapp.mspx
'about this feature!

'Here I filter on date so I wil only have 1 item returned!!
strFilter = "[Start] = " & Quote(DateValue("11-07-2006") & "
23:59") & " And " & _
"[End] " & Quote(DateValue("11-07-2006") & " 0:00")
Dim myAppt As Outlook.AppointmentItem
Dim strMsg As String = ""

objTest = objItems.Restrict(strFilter)
myAppt = objTest.GetFirst
Dim sPrevEntryID As String = ""
Dim iRecurrCount As Integer = 1
' Get the StoreID, which is a property of the folder
StoreID = objFolder.StoreID

'This loop will be entered only one time in this case!
Do While TypeName(myAppt) "Nothing"
strMsg = ""
strMsg = strMsg & vbLf & myAppt.Subject & "Nr:" & iRecurrCount
strMsg = strMsg & " at " & Format(myAppt.Start, "hh:mm") &
vbCrLf
MsgBox(strMsg)
iRecurrCount = iRecurrCount + 1
sPrevEntryID = myAppt.EntryID
Item = olns.GetItemFromID(myAppt.EntryID, StoreID)

'Item.display()
Dim oAgendaItem As Outlook.AppointmentItem = Item
oAgendaItem.Body = "Adjust Body text :-)"
oAgendaItem.Save() 'After this statement all 10 items are
adjusted!!!
myAppt = objTest.GetNext
Loop








All times are GMT +1. The time now is 05:30 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-2006 OutlookBanter.com