|
-
Mar 8th, 2005, 12:29 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Permanently Delete Outlook Items
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.
Last edited by kzatu; Mar 9th, 2005 at 07:29 PM.
Changes are not permanent, but change is. {Neil Peart}
-
Mar 8th, 2005, 03:06 PM
#2
Re: Permanently Delete Outlook Items
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 9th, 2005, 07:29 PM
#3
Thread Starter
Addicted Member
Re: Permanently Delete Outlook Items
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!
Changes are not permanent, but change is. {Neil Peart}
-
Mar 9th, 2005, 07:48 PM
#4
Re: Permanently Delete Outlook Items
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|