Skip to main content

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

Author: Xiaoyang Last Modified: 2024-08-08

If you need to send an email message from a Word document via Outlook, and attach the current Word file as well, you can create a command button, and then, send the message by clicking this button without opening the Outlook. This article, I will introduce how to deal with it quickly and easily.

Apply a button to send email with current Word file attached


Apply a button to send email with current Word file attached

Please do with the following steps for solving this job in Word file:

1. First, you should create a command button, please click Developer > Legacy Tools > Command Button(ActiveX Control), see screenshot:

Developer tab with Controls group selected, Legacy Tools clicked, and Command Button highlighted

2. Select the button, and click Properties under the Developer tab, in the Properties pane, type the caption text you need into the Caption field, see screenshot:

Properties button on the ribbon and Properties dialog popped up

3. Then, close the Properties pane, now, right click the button, and choose View Code, see screenshot:

View Code option on the context menu

4. And then, in the displayed Microsoft Visual Basic for Applications window, copy and paste the below code between the original scripts, see screenshot:

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: In the above code, you should change the subject, body text or sent address to your need.

5. Then, save and close this code, click Design Mode to turn off the design mode. Now, when clicking the command button you have created, an email will be created with the current Word document as attachment, see screenshot:

An email is created with the current Word document as an attachment

6. At last, you just need to click Send button to send this message.

Best Office Productivity Tools

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

๐Ÿค– Kutools AI Features: Generate Content / Rewrite Text / Document Q&A / Get Quick Answers / Translate documents / Polish Document (Preserve Format)...

๐Ÿ“˜ 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...

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