QuickSteps Week, Part 4

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 Reply & Delete QuickStep.

Opens a reply to the selected message, and then deletes the original message.

This one is another simple QuickStep. Just reply to the currently selected or open item, then delete the original. Note that the original is deleted even if you cancel the reply (the macro isn't smart enough to figure that out).

Sub ReplyAndDelete()

  On Error GoTo ErrorHandler

  Dim currentObject As Object
  Dim msg As Outlook.MailItem
  Dim newMessage As Outlook.MailItem

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

  ' act on 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

  ' create reply and display for editing
  Set newMessage = msg.Reply
  newMessage.Display

  ' delete original
  With msg
    .UnRead = False
    .Delete
  End With

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 AddReplyAndDeleteButton()
Call AddToolbarButton("Reply and Delete", "Reply to selected e-mail and delete original", _
                        "ReplyAndDelete", , 328, 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 »


Related Articles:


Share This Article:

Share and bookmark this articledelicious buttonfacebook buttonlinkedin buttonstumbleupon buttontwitter button

comment bubble 2 Comment(s) on QuickSteps Week, Part 4:

  1. Tips Comp writes:

    Hi – finally found someone who can possibly assist with some repetitive tasks at our office that are embarassing when we make mistakes. If you can refer me to books, website information or even developers we might pay to assist I would really appreciate it.
    Simple things like:
    Putting today's date in the subject field of the email
    Incrementing newsletter number in the subject field
    Creating the next newsletter and saving it in drafts when the current one is sent
    Placing a copy of an outlook template in a templates folder in the inbox as well as the default folder they are saved in

    Thanks heaps

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