[VBA] How to Preview Email Content in Outlook Before Sending

目次

Environment

  • OS: Windows 10 Pro
  • Software: Microsoft Outlook, Excel VBA

Background

While automating email distribution using VBA is efficient, there are many cases where you might want to double-check the “To” or “CC” fields—especially when dealing with external clients or dynamic recipients.

This article explains how to bring up the Outlook mail window so you can review and manually click “Send” after verification.

The Solution: Using the “.Display” Method

In Outlook VBA, the .Display method is used to show the created mail item on your screen. This replaces the .Send method, which would otherwise send the email immediately without any visual feedback.

Code Example

Sub SendEmail()

    Dim objOutlook As Outlook.Application
    Dim objMail As Outlook.MailItem
    Dim wsMail As Worksheet

    ' Initialize objects
    Set objOutlook = New Outlook.Application
    Set wsMail = ThisWorkbook.Sheets(1)
    Set objMail = objOutlook.CreateItem(olMailItem)

    ' Save the workbook before proceeding
    ActiveWorkbook.Save

    With wsMail
        objMail.To = .Range("A6").Value         ' Recipient
        objMail.CC = .Range("B6").Value         ' CC
        objMail.Subject = .Range("C6").Value    ' Subject
        objMail.BodyFormat = olFormatPlain      ' Plain text format
        objMail.Body = .Range("D6").Value       ' Body content
        
        ' --- THE KEY POINT ---
        objMail.Display ' Displays the email on screen instead of sending it
    End With

End Sub

Code Explanation

  • Lines 2–4: Declare variable types for Outlook, the mail item, and the worksheet.
  • Lines 6–8: Initialize the objects.
  • Line 10: Saves the active workbook automatically when the macro runs.
  • Lines 12–19: Within the With block, the macro maps cell values to email properties:
    • .To / .CC: Sets recipients. You can concatenate multiple addresses using &.
    • .BodyFormat: Set to olFormatPlain for simple text.
    • .Display: This command opens the actual Outlook compose window. Unlike .Send, it allows the user to make manual edits or final checks.

Pro-Tip: Adding a User Guide

To make the tool even more user-friendly, you can add a MsgBox after the .Display command:

objMail.Display
MsgBox "Please review the email in Outlook and click Send manually.", vbInformation

This ensures the user knows they are expected to take the final action, preventing them from forgetting to hit the send button after the window pops up.

Summary

By using the .Display method in your Outlook VBA macros, you can:

  1. Prevent accidental sends to wrong addresses.
  2. Manually customize parts of the email that are hard to automate.
  3. Build confidence in your automation tools before moving to full auto-send.

This is a highly recommended technique for anyone who wants to manage their professional communications with both speed and accuracy.

よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

この記事を書いた人

私が勉強したこと、実践したこと、してることを書いているブログです。
主に資産運用について書いていたのですが、
最近はプログラミングに興味があるので、今はそればっかりです。

目次