Skip to main content

How to apply a button to send email with current Word file attached?

Author Xiaoyang Last modified

If you need to send an email from a Word document using Outlook and attach the current Word file, you can insert a command button that sends the email with one click - no need to open Outlook manually. This guide shows how to set it up quickly and easily.

Apply a button to send email with the current Word file attached


Apply a button to send email with the current Word file attached

Please follow these steps to accomplish the task in your Word document:

  1. First, insert a command button. Go to "Developer" > "Legacy Tools" > "Command Button (ActiveX Control)".

    Note: If you don’t see the Developer tab in the ribbon, visit: How to show the Developer tab in Word ribbon.

    Developer tab with Controls group selected, Legacy Tools clicked, and Command Button highlighted
  2. Select the button, then click "Properties" under the "Developer" tab. In the Properties pane, type the text you want to display on the button in the "Caption" field.
    Properties button on the ribbon and Properties dialog popped up
  3. Close the Properties pane. Then right-click the button and choose "View Code".
    View Code option on the context menu
  4. In the "Microsoft Visual Basic for Applications" window, paste the following code between the existing subroutine tags:
    Dim xOutlookObj As Object
    Dim xEmail As Object
    Dim xDoc As Document
    Application.ScreenUpdating = False
    Set xOutlookObj = CreateObject("Outlook.Application")
    Set xEmail = xOutlookObj.CreateItem(olMailItem)
    Set xDoc = ActiveDocument
    xDoc.Save
    With xEmail
        .Subject = "Fax-data"
        .Body = "This is a test email."
        .To = "yy@addin99.com"
        .Importance = olImportanceNormal
        .Attachments.Add xDoc.FullName
        .Display
    End With
    Set xDoc = Nothing
    Set xEmail = Nothing
    Set xOutlookObj = Nothing
    Application.ScreenUpdating = True
    VBA window with the above code pasted

    Note: You can change the subject, body content, and recipient email address in the code to match your actual message details.

  5. Save and close the VBA editor. Click "Design Mode" on the Developer tab to turn it off. Now, when you click the command button, an email is automatically created in Outlook with the current Word document attached.
    An email is created with the current Word document as an attachment
  6. Finally, click the "Send" button in Outlook to send the message.

Best Office Productivity Tools

Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!

πŸ€– Kutools AI Features: AI Assistant / Real-Time Assistant / Super Polish (Preserve Format) / Super Translate (Preserve Format) / AI Redaction / AI Proofread...

πŸ“˜ Document Mastery: Split Pages / Merge Documents / Export Selection in Various Formats (PDF/TXT/DOC/HTML...) / Batch Convert to PDF...

✏ Contents Editing: Batch Find and Replace across Multiple Files / Resize All Pictures / Transpose Table Rows and Columns / Convert Table to Text...

🧹 Effortless Clean: Sweap away Extra Spaces / Section Breaks / Text Boxes / Hyperlinks / For more removing tools, head to the Remove group...

βž• Creative Inserts: Insert Thousand Separators / Check Boxes / Radio Buttons / QR Code / Barcode / Multiple Pictures / Discover more in the Insert group...

πŸ” Precision Selections: Pinpoint Specific Pages / Tables / Shapes / Heading Paragraphs / Enhance navigation with more Select features...

⭐ Star Enhancements: Navigate to Any Location / Auto-Insert Repetitive Text / Toggle Between Document Windows / 11 Conversion Tools...

🌍 Supports 40+ Languages: Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Kutools and Kutools Plus tabs on the Word Ribbon
πŸ‘‰ Want to try these features? Download Kutools for Word now! πŸš€
 

Best Office Productivity Tools

Kutools for Word - 100+ Tools for Word