How to apply a button to send email with current Word file attached?
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.
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:
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:
3. Then, close the Properties pane, now, right click the button, and choose View Code, see screenshot:
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 xEmile As Object Dim xDoc As Document Application.ScreenUpdating = False Set xOutlookObj = CreateObject("Outlook.Application") Set xEmile = xOutlookObj.CreateItem(olMailItem) Set xDoc = ActiveDocument xDoc.Save With xEmile .Subject = "Fax-data" .Body = "This is a test email." .To = "email@example.com" .Importance = olImportanceNormal .Attachments.Add xDoc.FullName .Display End With Set xDoc = Nothing Set xEmail = Nothing Set xOutlookObj = Nothing Application.ScreenUpdating = True
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:
6. At last, you just need to click Send button to send this message.
Recommended Productivity Tools
- Complicated and repeated operations can be done a one-time processing in seconds.
- Insert multiple images across folders into Word document at once.
- Merge and combine multiple Word files across folders in to one with your desired order.
- Split the current document into separate documents according to heading 1, section break or other criteria.
- Convert files between Doc and Docx, Docx and PDF, collection of tools for common conversions and selection, and so on...