![]() |
|
#1
|
|||
|
|||
|
I have tried 4 different macros found from web searches to permanently delete a mail item, but none of them worked for me at all. They either did nothing or gave runtime errors.
I have a Quick Step that I can use, but would prefer a macro that I can assign to the QAT. The Outlook VBA online reference and object browser are very close to useless to me. And I haven't been able to find much in the way of books for VBA in Outlook 2013. Does anyone have code that works in 2013, and/or the name of a good book for 2013 VBA? Any help is greatly appreciated! |
|
#2
|
||||
|
||||
|
Have you tried using Shift-Delete? No macros required.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
I know about Shift-Delete, and I have a Quick Step item to do a Permanent Delete, but was looking for a macro solution to add to my Quick Access Toolbar. But thanks anyway Paul.
|
|
#4
|
||||
|
||||
|
You can delete an item from a folder with VBA, but it then goes into the Deleted items folder, so you need to delete it from there also. This is easy to do if there is nothing in the deleted items folder, or if the deleted item is the latest item in the deleted folder. If not you are going to have to search for it e.g. as follows.
Code:
Sub DeleteSelectedItem()
'Graham Mayor - http://www.gmayor.com - Last updated - 01 Jan 2018
Dim olItem As Object
Dim lngDel As Long
Dim strSubject As String
Dim strDate As String
Dim objDeletedFolder As Folder
Set objDeletedFolder = Session.GetDefaultFolder(olFolderDeletedItems)
On Error Resume Next
Set olItem = ActiveExplorer.Selection.Item(1)
strSubject = olItem.Subject
strDate = olItem.CreationTime
olItem.Delete
For lngDel = objDeletedFolder.Items.Count To 1 Step -1
With objDeletedFolder.Items(lngDel)
If .Subject = strSubject And .CreationTime = strDate Then
objDeletedFolder.Items(lngDel).Delete
Exit For
End If
End With
Next lngDel
lbl_Exit:
Set objDeletedFolder = Nothing
Set olItem = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#5
|
|||
|
|||
|
Thanks, Graham. This code should work just fine. I do find it interesting that there appears to be no way in a single "command" in VBA to permanently delete an item, yet there is such an action available in both rules and Quick Steps.
Happy New Year! Alan (molechaser) |
|
| Tags |
| 2013, delete, vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to permanently delete emails out of trash | Andoheb | Outlook | 0 | 12-22-2015 05:18 AM |
| Outlook 2013/Outlook.com issue: mail won't delete in bulk, continually disconnects | davidvkimball | Outlook | 0 | 04-28-2014 11:58 AM |
Macro Delete Selected Text
|
smonczka | Word VBA | 2 | 11-05-2011 03:18 AM |
| delete email message via blackberry and have it delete on my pop3 and my outlook | Iamthestorm | Outlook | 2 | 10-28-2010 12:21 AM |
| Delete files permanently | rec | Word | 2 | 08-05-2010 01:12 PM |