M
Mark Allen
Hi,
I am having trouble with the following code.
I want to move all items from the one folder to another.
I can only seem to move half of the items in the folder.
Is there any mistake in the code?
Thanks in advance
Mark
ption Explicit
Private WithEvents objOLApp As Outlook.Application
Private Sub AddinInstance_OnConnection(ByVal Application
As Object, _
ByVal ConnectMode As
AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
Set objOLApp = Application
End Sub
Private Sub objOLApp_ItemSend(ByVal Item As Object, Cancel
As Boolean)
Dim objNamespace As Outlook.NameSpace
Dim objSentbox As Outlook.MAPIFolder
Dim objSentFolder As Outlook.MAPIFolder
Dim objDefSentFolder As Outlook.MAPIFolder
Set objNamespace = objOLApp.GetNamespace("MAPI")
Set objDefSentFolder = objNamespace.GetDefaultFolder
(olFolderSentMail)
Set objSentbox = objNamespace.Folders("Local Folders
stored on h drive")
Set objSentFolder = objSentbox.Folders("Sent Items")
Item.SaveSentMessageFolder objSentFolder
If objDefSentFolder.Items.Count > 0 Then
For Each Item In objDefSentFolder.Items
Item.Move objSentFolder
Next Item
End If
Set objSentbox = Nothing
Set objSentFolder = Nothing
Set objDefSentFolder = Nothing
Set objNamespace = Nothing
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode
As _
AddInDesignerObjects.ext_DisconnectMode, custom
() As Variant)
Set objOLApp = Nothing
End Sub
I am having trouble with the following code.
I want to move all items from the one folder to another.
I can only seem to move half of the items in the folder.
Is there any mistake in the code?
Thanks in advance
Mark
ption Explicit
Private WithEvents objOLApp As Outlook.Application
Private Sub AddinInstance_OnConnection(ByVal Application
As Object, _
ByVal ConnectMode As
AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
Set objOLApp = Application
End Sub
Private Sub objOLApp_ItemSend(ByVal Item As Object, Cancel
As Boolean)
Dim objNamespace As Outlook.NameSpace
Dim objSentbox As Outlook.MAPIFolder
Dim objSentFolder As Outlook.MAPIFolder
Dim objDefSentFolder As Outlook.MAPIFolder
Set objNamespace = objOLApp.GetNamespace("MAPI")
Set objDefSentFolder = objNamespace.GetDefaultFolder
(olFolderSentMail)
Set objSentbox = objNamespace.Folders("Local Folders
stored on h drive")
Set objSentFolder = objSentbox.Folders("Sent Items")
Item.SaveSentMessageFolder objSentFolder
If objDefSentFolder.Items.Count > 0 Then
For Each Item In objDefSentFolder.Items
Item.Move objSentFolder
Next Item
End If
Set objSentbox = Nothing
Set objSentFolder = Nothing
Set objDefSentFolder = Nothing
Set objNamespace = Nothing
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode
As _
AddInDesignerObjects.ext_DisconnectMode, custom
() As Variant)
Set objOLApp = Nothing
End Sub