Hello All,
Please first let me apologise if I have posted in correctly. I am new to this forum and the world of VBA.
I have a script that deletes items from my outlook mailbox to a personal archive delete folder. It is working but I have noticed that emails are going to this folder but anything else such as calendar items are being moved to the "Drafts" folder. I have posted my script below and would appreciate any help and assistance in showing me where I have made a mistake or need to change anything.
Thank You
Sub MoveDeletedItems()
'Move messages from Exchange mailbox folder "Deleted Items" to "Application&Monitoring" personal folder's "Deleted Items" folder.
'Dim and Set
Dim objFolder As Outlook.MAPIFolder
Set objFolder = Outlook.Application.GetNamespace("MAPI").Folders("Application&Monitoring").Folders("Deleted Items")
Dim objTrash As Outlook.Items
Set objTrash = Outlook.Application.Session.GetDefaultFolder(olFolderDeletedItems).Items
Dim objItem As Object
'End Dim and Set
'Move Items
For Each objItem In objTrash
If objItem.Class Then
objItem.Move objFolder
End If
Next
'End Move Items
'Cleanup
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
'End Cleanup
End Sub
Please first let me apologise if I have posted in correctly. I am new to this forum and the world of VBA.
I have a script that deletes items from my outlook mailbox to a personal archive delete folder. It is working but I have noticed that emails are going to this folder but anything else such as calendar items are being moved to the "Drafts" folder. I have posted my script below and would appreciate any help and assistance in showing me where I have made a mistake or need to change anything.
Thank You
Sub MoveDeletedItems()
'Move messages from Exchange mailbox folder "Deleted Items" to "Application&Monitoring" personal folder's "Deleted Items" folder.
'Dim and Set
Dim objFolder As Outlook.MAPIFolder
Set objFolder = Outlook.Application.GetNamespace("MAPI").Folders("Application&Monitoring").Folders("Deleted Items")
Dim objTrash As Outlook.Items
Set objTrash = Outlook.Application.Session.GetDefaultFolder(olFolderDeletedItems).Items
Dim objItem As Object
'End Dim and Set
'Move Items
For Each objItem In objTrash
If objItem.Class Then
objItem.Move objFolder
End If
Next
'End Move Items
'Cleanup
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
'End Cleanup
End Sub