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