I have code that runs through special folders in Outlook and deletes items that meet criteria. When I execute the item.delete method, it goes into my deleted items folder when I would prefer to have it permanently deleted.
Printable View
I have code that runs through special folders in Outlook and deletes items that meet criteria. When I execute the item.delete method, it goes into my deleted items folder when I would prefer to have it permanently deleted.
You can just delete the item from the Deleted Items folder after its deleted.
VB Code:
Sub DeleteMyItem() Dim myolApp As New Outlook.Application Dim oNamespace As Outlook.NameSpace Dim oFolder As Outlook.MAPIFolder Dim oItem As Object Dim strPrompt As String Set oNamespace = myolApp.GetNamespace("MAPI") Set oFolder = oNamespace.GetDefaultFolder(olFolderTasks) Set oItem = oFolder.Items.Item(1) 'Prompt the user for confirmation strPrompt = "Are you sure you want to delete the item?" If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then oItem.Subject = "DeleteMe" oItem.Save oItem.Move oNamespace.GetDefaultFolder(olFolderDeletedItems) Set oItem = Nothing Set oItem = oNamespace.GetDefaultFolder(olFolderDeletedItems).Items.Find("[Subject] = DeleteMe") oItem.Delete Set oItem = Nothing MsgBox ("Item deleted") End If End Sub
LOL, I thought I might have to go that far, I was just hoping not to. But all the same, if it works it works.
Thanks!
Well, I sure there is actually a way, but I havent found it yet. Since you can do it with pressing the
"Shift" + "Delete" keys you theoretically should be able to do it through the OOM unless its
hidden or protected. :(