Resend This Message

How to assign a macro to a toolbar button

Outlook Code to resend messages

The following VBA code, placed in a standard module in the Outlook VBE, can be run on-demand via a toolbar button to execute the "Resend This Message…" function on the Actions menu of an open email.

As most Outlook users know, you can open a sent email and click "Resend This Message…" on the Actions menu. This constructs a copy of the original email as if you were sending it again, with the original body, To and Cc preserved. All you have to do is fill in the subject, change a few relevant details and click Send. This method is perfect if you are sending the same email every day or every week to the same recipients and you are just updating a few minor details, like a weekly status report.

Just like some of the other Outlook code found here, you can also run it from the Explorer window, it will simply act on the currently selected email. Don't select or open more than one message before running this code. If you do run it from the Explorer window, it temporarily opens the email, then closes it at the end, so you will see the screen flash a bit.

One thing this code does which "Resend This Message…" doesn't do is pull the original subject line into the new email!

Sub ResendMsg()
' "Resend This Message..." functionality
    Dim myItem As Outlook.MailItem
    Dim objInsp As Outlook.Inspector
    Dim objActionsMenu As Office.CommandBarControl
    Dim olNewMailItem As Outlook.MailItem

    ' get valid ref to current item
    On Error Resume Next
    Select Case TypeName(Application.ActiveWindow)
        Case "Explorer"
            Set myItem = ActiveExplorer.Selection.Item(1)
        Case "Inspector"
            Set myItem = ActiveInspector.CurrentItem
        Case Else
    End Select
    On Error GoTo 0

    If myItem Is Nothing Then
        MsgBox "Could not use current item. Please select or open a single email.", _
        GoTo exitproc
    End If

    ' find "Resend This Message" control
    Set objInsp = ActiveInspector
    Set objActionsMenu = objInsp.CommandBars.FindControl(, 3165)

    ' resend message

    ' get object reference to new mail to play with it
    Set olNewMailItem = ActiveInspector.CurrentItem

    olNewMailItem.Subject = myItem.Subject

    ' close orig email
    myItem.Close olDiscard

Set myItem = Nothing
Set objInsp = Nothing
Set objActionsMenu = Nothing
Set olNewMailItem = Nothing

End Sub

How to assign a macro to a toolbar button

While viewing an email or in the main Explorer window, hover your mouse pointer over a toolbar, right-click and choose 'Customize'. Or go to View>Toolbars>Customize. On the "Commands" tab, in the "Categories" list, click "Macros." The list of macros you created should appear.

Click and drag the appropriate macro to the toolbar of your choice. If you are in the main Explorer window, this would either be the Standard or Advanced toolbar. If you are viewing a email, it would be either the Standard or Formatting toolbar.

Once you drop the macro on the toolbar, right-click it and customize the display name, icon, etc.

You might be wondering how I figured out the ID number of the "Resend This Message…" control. I found some code on MSDN that, when placed in a standard module in Excel, will produce a workbook showing all of the control IDs and names for every control available to the Explorer and Inspector objects. Remember to set an object reference to the Outlook object library (see the Binding page for instructions).

Read this this Microsoft KB article to get the code.

To find out how to add macros to toolbar buttons in later versions of Outlook, visit Create a button for a macro.

Site last updated: August 20, 2014

learn excel dashboards