Exchange Server TechCenter >
Exchange Server Forums
>
Development
>
Getting All deleted appointment from Calendar folder
Getting All deleted appointment from Calendar folder
- Hello,
I am trying to findout itemid of all deleted appointment but i could not make it. does anyone used it . I am in kind of trouble.I deleted many appointment but never able to get Id for those appointment. i would appreciate your earlier response. here is code. as you see my code i am getting new created/update item without any problem but somehow i am unable to get deleted appointment id. does anyone know why...
Dim request As New SyncFolderItemsType()
request.MaxChangesReturned = 512
Dim InboxFolderID As New DistinguishedFolderIdType()
InboxFolderID.Id = DistinguishedFolderIdNameType.calendar
request.SyncFolderId = New TargetFolderIdType()
request.SyncFolderId.Item = InboxFolderID
Dim itemProperties As New ItemResponseShapeType
itemProperties.BaseShape = DefaultShapeNamesType.IdOnly
request.ItemShape = itemProperties
Dim strMySyncID As String
strMySyncID = "H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/In6NX+PX+TXoOfjF+w+P9+/d3znePnlwfLC9f3xyb/vJyZOT7Wd7Tw5Onjx49vD+/Z1f8t3X49fXy+nrNmvzk2yZ1de/xqP3f/NZVc7y+mz2azx8/3d/Mq+bolr+Gofv/+p36f/1IqvfypCTX+PX+C3oa0WmzRcNWv4avzl9tUP/H6PNH/Wb/Br/9Z/2D/8Xn/+5//Wf+wt+1e9SXP+av8bf8u/97b/R5V/+G3znL/j8T/8//sq//tea/xq/xq/5F/4y+vfX+jV+E/o/Pb/+r/Fr/Ff044vjl2dfHL/AJ7/Gs/vPfvLXpp9/Cf3/0a/hnpf0/1/g/b2k/+97fw89X/3x/+lf8O0/8xef/Mlf/hrr32P8Z/yur/jTX/PX+tu//DP/gz+39+2v82t894/8DV79GX/Zn/kHvPw1f61f59Xf/l//V0/+pd/tyb/9uz35T363l7/u8je49xMfv/w17n752emyuarqdp6+ns6rqrz75Vefnb54/d0vX7359t3p8rNX+bRYFfmybfBX065n9Pvu7q/x6Nf6NX6N/wcClXUSRAIAAA=="
request.SyncState = strMySyncID
Dim response As SyncFolderItemsResponseType = service.SyncFolderItems(request)
Dim responseMessage As SyncFolderItemsResponseMessageType = TryCast(response.ResponseMessages.Items(0), SyncFolderItemsResponseMessageType)
If responseMessage.ResponseCode <> ResponseCodeType.NoError Then
Throw New Exception("SyncFolderItems failed with response code: " & responseMessage.ResponseCode.ToString())
End If
Dim deleteitems As New List(Of ItemIdType)
Dim createitems As New List(Of ItemType)
Dim updateitems As New List(Of ItemType)
For index As Integer = 0 To responseMessage.Changes.Items.Length - 1
Select Case (responseMessage.Changes.ItemsElementName(index))
Case ItemsChoiceType2.Delete
Dim delete As SyncFolderItemsDeleteType = TryCast(responseMessage.Changes.Items(index), SyncFolderItemsDeleteType)
deleteitems.Add(delete.ItemId)
Case ItemsChoiceType2.Create
Dim create As SyncFolderItemsCreateOrUpdateType = TryCast(responseMessage.Changes.Items(index), SyncFolderItemsCreateOrUpdateType)
createitems.Add(create.Item)
Case ItemsChoiceType2.Update
Dim update As SyncFolderItemsCreateOrUpdateType = TryCast(responseMessage.Changes.Items(index), SyncFolderItemsCreateOrUpdateType)
updateitems.Add(update.Item)
End Select
strMySyncID = responseMessage.SyncState
Next- Edited byExchange_buddy Friday, October 30, 2009 5:59 PMadded new line
All Replies
- You are performing a complete sync. I believe items that were both created and deleted are optimized out.
David Claux | Program Manager - Exchange Web Services- Proposed As Answer byDavid Claux - MSFT Monday, November 02, 2009 3:27 AM
- the created item work fine from following code but its not bringing any deleted appointment if i delete any appointment in calendar. I checked the documentation and it mentioned that it should bring delete item from following code , any idea why only delete appointment not coming up.
- As indicated, I believe that with a full synchronization (as opposed to as catch-up synchronization where you pass a SyncState to SyncFolderitems) items that were both created and deleted are optimized out, that is, you doi not get either a create nor a delete change.
David Claux | Program Manager - Exchange Web Services - Hi David,
even if i do full synchronization its not bringing me the deleted record from same code but able to bring created records. I just pasted code below
Dim request As New SyncFolderItemsType()
request.MaxChangesReturned = 512
Dim InboxFolderID As New DistinguishedFolderIdType()
InboxFolderID.Id = DistinguishedFolderIdNameType.calendar
request.SyncFolderId = New TargetFolderIdType()
request.SyncFolderId.Item = InboxFolderID
Dim itemProperties As New ItemResponseShapeType
itemProperties.BaseShape = DefaultShapeNamesType.IdOnly
request.ItemShape = itemProperties
Dim response As SyncFolderItemsResponseType = service.SyncFolderItems(request)
Dim responseMessage As SyncFolderItemsResponseMessageType = TryCast(response.ResponseMessages.Items(0), SyncFolderItemsResponseMessageType)
If responseMessage.ResponseCode <> ResponseCodeType.NoError Then
Throw New Exception("SyncFolderItems failed with response code: " & responseMessage.ResponseCode.ToString())
End If
Dim deleteitems As New List(Of ItemIdType)
Dim createitems As New List(Of ItemType)
Dim updateitems As New List(Of ItemType)
For index As Integer = 0 To responseMessage.Changes.Items.Length - 1
Select Case (responseMessage.Changes.ItemsElementName(index))
Case ItemsChoiceType2.Delete
Dim delete As SyncFolderItemsDeleteType = TryCast(responseMessage.Changes.Items(index), SyncFolderItemsDeleteType)
deleteitems.Add(delete.ItemId)
Case ItemsChoiceType2.Create
Dim create As SyncFolderItemsCreateOrUpdateType = TryCast(responseMessage.Changes.Items(index), SyncFolderItemsCreateOrUpdateType)
createitems.Add(create.Item)
Case ItemsChoiceType2.Update
Dim update As SyncFolderItemsCreateOrUpdateType = TryCast(responseMessage.Changes.Items(index), SyncFolderItemsCreateOrUpdateType)
updateitems.Add(update.Item)
End Select
Next - I'm sorry but my answer is still the same: when you do a full sync (which is what your code above does) you do not receive any event for items that were both created and deleted. For example, take the following sequence of events:
Item1 is created
Item2 is created
Item1 is deleted
Now synchronize, and the only event you will receive is "Item2 was created".
I suggest you take a closer look at the changes returned by SyncFolderItems. There won't be any create event for items that have been deleted.
David Claux | Program Manager - Exchange Web Services- Proposed As Answer byDavid Claux - MSFT Tuesday, November 03, 2009 11:42 PM
- yes you are right David, it would not give me that item which was deleted after creation. do you know how i can solve this mystery. basically my job is to get all those appointment which was deleted in specific date range. do you have any idea is it possible to retrieve those item I know after deleting appointment it come to deleted folder but if you delete any instance of recurring event series then it would not come in deleted folder so i cant read all deleted folder for this task. please advice me how i can solve it.
It's not a mystery, it's the way SyncFolderItems works :)
There is no way to query for all deleted items between two dates. If you want to be notified of deleted items, you need a running application that either:
- Periodically performs catch-up synchronization (SyncFolderItems with a SyncState) but you will still miss items that were created then deleted between two synchronizations,
- Or subscribes to notifications, which is the preferred way. Please consult the documentation to know more about notifications in EWS.
Additionally, I would strongly recommend you use the EWS Managed API instead of auto-generated proxies. It will make your life easier.
David Claux | Program Manager - Exchange Web Services- Proposed As Answer byDavid Claux - MSFT Wednesday, November 04, 2009 3:14 AM
- Unproposed As Answer byExchange_buddy Monday, November 23, 2009 8:45 AM
- Hello David, thank you for your reply. I am looking for notification document now on technet. I am stuck right now to read appointment data which come in created or update list item. I need to read subject,location,categories,body,date start and end for each appointment but from this way i can only able to read subject how i can solve this problem . below is the code.
For itm As Integer = 0 To updateitems.Count - 1
'MessageBox.Show(updateitems.Item(itm).Body.Value.ToString)
MessageBox.Show(updateitems.Item(itm).Subject.ToString())
MessageBox.Show(updateitems.Item(itm).Categories.ToString())
MessageBox.Show(updateitems.Item(itm).DateTimeReceived.ToString())
MessageBox.Show(updateitems.Item(itm).DateTimeSent.ToString())
MessageBox.Show(updateitems.Item(itm).ItemId.Id)
Next - Hello David,
I have scenerio in first syncstate i have some item id stored in my database which was created. some of them were deleted after i pulled in to my application, so when i do 2nd syncronization i need to know which was deleted from first sync. can anyone help me please.


