Results 1 to 4 of 4

Thread: [RESOLVED] Permanently Delete Outlook Items

  1. #1

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Resolved [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}

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Permanently Delete Outlook Items

    You can just delete the item from the Deleted Items folder after its deleted.
    VB Code:
    1. Sub DeleteMyItem()
    2.     Dim myolApp As New Outlook.Application
    3.     Dim oNamespace As Outlook.NameSpace
    4.     Dim oFolder As Outlook.MAPIFolder
    5.     Dim oItem As Object
    6.     Dim strPrompt As String
    7.    
    8.     Set oNamespace = myolApp.GetNamespace("MAPI")
    9.     Set oFolder = oNamespace.GetDefaultFolder(olFolderTasks)
    10.     Set oItem = oFolder.Items.Item(1)
    11.  
    12.     'Prompt the user for confirmation
    13.     strPrompt = "Are you sure you want to delete the item?"
    14.     If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
    15.         oItem.Subject = "DeleteMe"
    16.         oItem.Save
    17.         oItem.Move oNamespace.GetDefaultFolder(olFolderDeletedItems)
    18.         Set oItem = Nothing
    19.         Set oItem = oNamespace.GetDefaultFolder(olFolderDeletedItems).Items.Find("[Subject] = DeleteMe")
    20.         oItem.Delete
    21.         Set oItem = Nothing
    22.         MsgBox ("Item deleted")
    23.     End If
    24. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    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}

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width