Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie - Move deleted items to archive

Status
Not open for further replies.

Minmoko6

Technical User
Nov 22, 2012
1
AU
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 [bigsmile]

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top