D
David Kleyman
Hello
I am trying to copy contacts from the default folder to a new one
I am using VB.NET and Outlook 2003
but it fails with this error
Error number 1248722935 Error description "Can't move the items."
Here is the code that does it
Could anybody take a look at it and let me know what's wrong?
Sub CopyItems(ByRef olApp As Microsoft.Office.Interop.Outlook.Application)
Dim olNS As Microsoft.Office.Interop.Outlook.NameSpace
Dim olSourceFolder, olTargetFolder As
Microsoft.Office.Interop.Outlook.MAPIFolder
Dim olMonticelloFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim items As Microsoft.Office.Interop.Outlook.Items
Dim item As Microsoft.Office.Interop.Outlook.ContactItem
Dim itemNew As Microsoft.Office.Interop.Outlook.ContactItem
Dim i As Short
Try
olNS = olApp.GetNamespace("MAPI")
olSourceFolder =
olNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFo
lderContacts)
For i = 1 To olNS.Folders.Count
If LCase(olNS.Folders.Item(i).Name) = "monticello" Then
olTargetFolder = olNS.Folders(i).Folders.Item("Monticello")
Exit For
End If
Next i
items = olSourceFolder.Items
If items.Count = 0 Then
MsgBox("No contacts to export")
Exit Sub
End If
For Each item In items
itemNew = CType(item.Copy, Microsoft.Office.Interop.Outlook.ContactItem)
itemNew.MessageClass = "IPM.Contact.MonticelloContact"
itemNew.Save()
itemNew.Move(olTargetFolder)
Next
MsgBox("All items exported!")
Catch ex As SystemException
MsgBox("Main.CopyItems - " & "Error #" & Err.Number & "-" & Err.Description,
MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "Monticello")
DebugWriter("Main.CopyItems", Err.Description)
End Try
End Sub
Thanks for your help
-David
I am trying to copy contacts from the default folder to a new one
I am using VB.NET and Outlook 2003
but it fails with this error
Error number 1248722935 Error description "Can't move the items."
Here is the code that does it
Could anybody take a look at it and let me know what's wrong?
Sub CopyItems(ByRef olApp As Microsoft.Office.Interop.Outlook.Application)
Dim olNS As Microsoft.Office.Interop.Outlook.NameSpace
Dim olSourceFolder, olTargetFolder As
Microsoft.Office.Interop.Outlook.MAPIFolder
Dim olMonticelloFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim items As Microsoft.Office.Interop.Outlook.Items
Dim item As Microsoft.Office.Interop.Outlook.ContactItem
Dim itemNew As Microsoft.Office.Interop.Outlook.ContactItem
Dim i As Short
Try
olNS = olApp.GetNamespace("MAPI")
olSourceFolder =
olNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFo
lderContacts)
For i = 1 To olNS.Folders.Count
If LCase(olNS.Folders.Item(i).Name) = "monticello" Then
olTargetFolder = olNS.Folders(i).Folders.Item("Monticello")
Exit For
End If
Next i
items = olSourceFolder.Items
If items.Count = 0 Then
MsgBox("No contacts to export")
Exit Sub
End If
For Each item In items
itemNew = CType(item.Copy, Microsoft.Office.Interop.Outlook.ContactItem)
itemNew.MessageClass = "IPM.Contact.MonticelloContact"
itemNew.Save()
itemNew.Move(olTargetFolder)
Next
MsgBox("All items exported!")
Catch ex As SystemException
MsgBox("Main.CopyItems - " & "Error #" & Err.Number & "-" & Err.Description,
MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "Monticello")
DebugWriter("Main.CopyItems", Err.Description)
End Try
End Sub
Thanks for your help
-David