QuickSteps Week, Part 3

QuickSteps image

Welcome to QuickSteps Week! This week we'll be going over a new Outlook 2010 feature called QuickSteps and how we can simulate some of these features in Outlook 2003 using VBA.

QuickSteps

Read previous QuickStep posts:

Each day we'll be going over a different built-in QuickStep, including how to add it to your Standard toolbar. Today we'll go over the Done QuickStep.

Moves the message to a specified mail folder, marks the message complete, and then marks it as read.

Finally a simple QuickStep! This one is nearly identical to the code for QuickSteps Week, Part 1, except here we also flag the e-mail as Complete.

Sub Done()

  On Error GoTo ErrorHandler

  Dim currentObject As Object
  Dim msg As Outlook.MailItem
  Dim folderToMove As Outlook.MAPIFolder

  ' grab the currently selected or open item
  Set currentObject = GetCurrentItem

  ' move mailitems only
  If TypeName(currentObject) <> "MailItem" Then
    MsgBox "This code works on e-mail messages only.", vbInformation
    GoTo ProgramExit
  Else
    Set msg = currentObject
  End If

  ' ask for folder
  Set folderToMove = Outlook.GetNamespace("MAPI").PickFolder

  If Not (folderToMove Is Nothing) Then

    ' mark as read and complete, move to folder
    With msg
      .UnRead = False
      .FlagStatus = olFlagComplete
      .Move folderToMove
    End With

  End If

ProgramExit:
  Exit Sub
ErrorHandler:
  MsgBox Err.Number & " - " & Err.Description
  Resume ProgramExit
End Sub

Add To Toolbar

Taken from Create Outlook toolbar buttons using VBA. This will assign the above macro to a toolbar button on the Standard toolbar.

Sub AddDoneButton()
Call AddToolbarButton("Done", "Move selected e-mail to folder and mark as complete/read", _
                        "Done", , 1679, msoButtonIconAndCaption)
End Sub

Visit Utility Functions for use with Outlook 2003 VBA for a copy of the GetCurrentItem procedure.

About JP

I'm just an average guy who writes VBA code for a living. This is my personal blog. Excel and Outlook are my thing, with a sprinkle of Access and Word here and there. Follow this space to learn more about VBA. Keep Reading »

Share This Article:

Share and bookmark this articledelicious buttonfacebook buttonlinkedin buttonstumbleupon buttontwitter button

Related Articles:



This article is closed to new comments. Why?
Random Data Generator