Jan Vojtech Vanicek
asked on
For Each ... Next VB.NET 2010 and Outlook 2010 problem
Hi experts,
Im writting little application for recursive move content of outlook folders to another. Nothing difficult.
Im using VS 2010 (Visual Basic) and Office 2010. All fully patched.
My code is easy for example:
Last contact or folder in each parent folder is not handled... Scary? please can you try it?
Is there any hotfix for that?
Following code is working as expected:
Im writting little application for recursive move content of outlook folders to another. Nothing difficult.
Im using VS 2010 (Visual Basic) and Office 2010. All fully patched.
My code is easy for example:
Private Sub WipeRecurse(RootFolder As Folder, DstFolder As Folder)
Dim cnt As ContactItem
For Each cnt in RootFolder.Items
cnt.Move(DstFolder)
Next
Dim sf As Folder
For Each sf in RootFolder.Folders
WipeRecurse(sf, DstFolder)
Loop
If RootFolder.FolderPath <> ComboBox2.SelectedItem Then
RootFolder.Delete()
End If
End Sub
Last contact or folder in each parent folder is not handled... Scary? please can you try it?
Is there any hotfix for that?
Following code is working as expected:
Private Sub WipeRecurse(RootFolder As Folder, DstFolder As Folder)
Dim cnt As ContactItem
Do Until RootFolder.Items.Count = 0
cnt = RootFolder.Items(RootFolder.Items.Count)
cnt.Move(DstFolder)
Loop
Dim sf As Folder
Do Until RootFolder.Folders.Count = 0
sf = RootFolder.Folders.Item(RootFolder.Folders.Count)
WipeRecurse(sf, DstFolder)
Loop
If RootFolder.FolderPath <> ComboBox2.SelectedItem Then
RootFolder.Delete()
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Interops are simply crap...
Open in new window
If that doesn't solve it, when running through in debug can you examine the Items collection or the Folders collection returned and see if what you expect to be returned is returned by the collection.