Home

Blog

Axel Segebrecht

Deleting IMAP Messages in Microsoft Outlook

If you like me are using Outlook at work to access your IMAP account(s) you probably are wondering whether there will ever be a simple way to move messages you want to delete to another folder (i.e. Trash). Sadly Outlook (2003) doesn’t like moving messages without leaving behind “messages that are marked for deletion”. That’s right, those fancy messages in your IMAP folders with a line going through them.

The only way to get rid of them and free up much needed space on your account is to “purge” your folders. Although this can be automated somehow, it’s really inconvenient for me. I prefer messages to be moved to my Trash folder for review and then permanently removed when I choose to. The last thing on my mind is remembering to clean up after a bit of software that should be doing this for me.

So what’s the solution?

I’ve looked through Outlook (2003) and found nothing.

I’ve queried the MS Knowledgebase and drew a blank (apart from the useful message quoted above earlier).

I’ve tried creating rules using the build-in “Rules Wizard” to no effect. There’s just no way to do it using rules in Outlook (2003).

I’ve tried “Visual Basic for Applications” (VBA) macro scripting… and hit pay dirt:

Reference: www.outlookcode.com

lafong (05-Jul-2005, 16:28)
Here’s a script to copy message(s) to a “Deleted Items” folder, then purge the current mailbox. You have to create a “Deleted Items” folder in your IMAP account. Seems to work for both POP “Personal Folders” too, if you use it accidentally, but not for Exchange(who cares). After making the macro you can create a toolbar button to activate it. I’m no vbs guru, so no guarantees.

by lafong – http://www.outlookcode.com/codedetail.aspx?id=427

Sub DeleteMessages()

Set myOlApp = CreateObject("Outlook.Application")

Dim myNameSpace As NameSpace

Set myNameSpace = myOlApp.GetNamespace("MAPI")

Dim myExplorer As Explorer

Set myExplorer = myOlApp.ActiveExplorer

'Get the folder type, expected type is 0 i.e. mail folder. If other type of folder
'being used then abort macro as it should only be used with mail folders.
folderType = myExplorer.CurrentFolder.DefaultItemType

'Check that folder is mail folder
If TypeName(myExplorer) = "Nothing" Or folderType <> 0 Then
GoTo invalidMailbox
End If

'Locate root folder for this account
Set thisFolder = myExplorer.CurrentFolder
Do Until thisFolder.Parent = myNameSpace
Set thisFolder = thisFolder.Parent
Loop
Set accountFolder = thisFolder

'Identify selected messages
Dim selectedItems As Selection
Set selectedItems = myExplorer.Selection
Dim currentMailItem As MailItem
Dim iterator As Long

'Run loop on selected messages
For iterator = 1 To selectedItems.Count
Set currentMailItem = selectedItems.Item(iterator)

'Move messages to Deleted Items folder
Set trashFolder = accountFolder.Folders("Deleted Items")
currentMailItem.Move (trashFolder)

Next

'Now, purge deleted messages
Dim myBar As CommandBar
Set myBar = Application.ActiveExplorer.CommandBars("Menu Bar")
Dim myButtonPopup As CommandBarPopup
Set myButtonPopup = myBar.Controls("Edit")
Dim myButton As CommandBarButton
Set myButton = myButtonPopup.Controls("Purge Deleted Messages")
myButton.Execute

Exit Sub

invalidMailbox:
MsgBox ("Macro configured only to work with mail folders! ")

Exit Sub

End Sub

Good luck and let me know how it works out for you.

Technorati Tags: · microsoft ·

View Comments to “Deleting IMAP Messages in Microsoft Outlook”

  1. Adrian says:
    June 13th, 2006 at 14:13

    I know its not quite what you are asking for, But its possible to group emails by status “pending deletion” or something to that effect. Which puts items awaiting deletion into their own group. And then you simply click the little – box at the side and thats them out of the way. Until you are ready to purge, or altertatively undelete.

    Hope thats of some help.

  2. Nick says:
    July 8th, 2006 at 13:14

    I had the same problem. As usual google turned up the answer:

    “To hide these deleted emails, choose View | Arrange By > Current View > Hide Messages Marked For Deletion”

    For more information, see here.

  3. Microsoft Outlook: Move E-Mail to IMAP Trash Folder in Outlook 2003, when message is "Deleted" says:
    July 19th, 2006 at 16:54

    [...] Greetings, jetnet !There is nothing natively in Outlook that will allow you to delete IMAP email to Trash. You can use a VBA Macro to move deleted email to Trashhttp://www.segebrecht.com/axel/computing/windows/deleting-imap-messages-in-microsoft-outlookBest wishes! [...]

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

blog comments powered by Disqus