Wednesday, April 4, 2007

Outlook Keyboard Shortcuts or button to Move a Message to a Folder

Are you a fan of the Google Gmail Archive button that moves your current message to the Archive so you never have to look for it again. Then this blog is for you. I walk you through how to create this functionality in Outlook 2003.
Create a macro in Outlook.
Sub ArchiveIt()
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder ' Folder where we want to move select of messages Dim objInbox As Outlook.MAPIFolder ' Archive Inbox
Dim objNS As Outlook.NameSpace Dim objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI") 'Find Domino Mailbox Set objInbox = objNS.Folders("Archive Folders") 'Find Archive Inbox Set objFolder = objInbox.Folders("Inbox")
'Assume this is a mail folder If objFolder Is Nothing Then MsgBox "This destination folder (called Inbox) doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER" End If
If Application.ActiveExplorer.Selection.Count = 0 Then 'Require that this procedure be called only when a message is selected Exit Sub End If
For Each objItem In Application.ActiveExplorer.Selection If objFolder.DefaultItemType = olMailItem Then If objItem.Class = olMail Then objItem.UnRead = False objItem.Move objFolder End If End If Next
Set objItem = Nothing Set objFolder = Nothing Set objInbox = Nothing Set objNS = Nothing
End Sub
Create a digital signature so it can be run again using the button or key stroke.
Run C:\Program Files\Microsoft Office\OFFICE11\SelfCert.exe
Use the digital signature to sign your macro:
Open the macro in the macro editor. Then go to Tools menu and click the Digital Signature menu item. Choose the certificate (if it is not already chosen).
Create a tool bar and toolbar button. Assign a key stroke to it if you like. That is it.

3 comments:

Anonymous said...

Fantastic macro! Good call on the "for each" which allows us to select multiple messages to be archived. I think I'll have to experiment with enabling other mail items as archiveable, as well (example: sys undeliverables).

Thanks again!

Brent V said...

Anonymous,

Thank you for the feedback. I have been using this for 9 months or so and it works great. There are indeed some items it does not archive such as meeting requests, sys undeliverables as you mentioned, and I think one other kind. If you figure that out, please share. :)

Enjoy,

Brent

public key infrastructure said...

Thanks a ton. Let me try this macro. Hoping that I will not get any more problem using it. If it works fine, I will certainly tell about it to my friends as well.