Consulting

Results 1 to 6 of 6

Thread: Solved: CDO Method to delete items programmatically

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Just A Dude VBAX Tutor Scottie P's Avatar
    Joined
    May 2004
    Location
    Remote from 18901 USA
    Posts
    263
    Location

    Solved: CDO Method to delete items programmatically

    Hi All.

    I was just wondering around the internet minding my own business when this code just jumped onto my clip board. Obviously curious, I tried it out - and it works great...for one item per click/run of the code.
    I have no knowledge in Outlook VBA so I would like to know this:

    Is there a way to have this work on a selection of multiple items?
    For instance, I select 5 items in the folder [items that I want to see go away for good] and hit the little 'Wipe 'em out' button and all 5 go...not just one each press of the button/run of the code.

    The code in question:

    [VBA]
    Sub DeleteSelectedItem()
    Dim objApp As Outlook.Application
    Dim objItem As Object
    Dim objCDO As MAPI.Message
    Dim objCDOSession As MAPI.Session
    Dim strEntryID As String
    Dim strStoreID As String

    Set objApp = CreateObject("Outlook.Application")
    Set objItem = objApp.ActiveExplorer.Selection.Item(1)
    If Not objItem Is Nothing Then
    Set objCDOSession = CreateObject("MAPI.Session")
    objCDOSession.Logon "", "", False, False
    strEntryID = objItem.EntryID
    strStoreID = objItem.Parent.StoreID
    Set objCDO = objCDOSession.GetMessage(strEntryID, strStoreID)
    If Not objCDO Is Nothing Then
    objCDO.Delete
    End If
    End If

    objCDOSession.Logoff
    Set objCDOSession = Nothing
    Set objItem = Nothing
    Set objCDO = Nothing
    Set objApp = Nothing
    End Sub
    [/VBA]

    Any takers?

    X
    Last edited by Scottie P; 06-12-2004 at 09:54 AM.
    Life is Visual: Presence is Perception...
    How we see the world is how we respond to it. ~* Peace *~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •