At times, you may want to import the contents of multiple Word documents into the body of one Outlook email. Now, in this post, we will help you achieve it in a jiffy.
After reading my previous article “How to Quickly Merge & Import the Contents of Multiple Text Files into an Outlook Email“, many users long for a rapid method to combine and import multiple Word documents into a single Outlook email. In the followings, we will introduce such a means.
Merge & Import Multiple Word Documents into One Email
- At the very outset, trigger Outlook VBA editor by referring to “How to Run VBA Code in Your Outlook“.
- Then, add “MS Word Object Library” with following the steps in “How to Add an Object Library Reference in VBA“.
- Afterwards, put the following VBA code into a module that is not being used.
Sub MergeImportMultipleWordDocumentsIntoOneEmail() Dim objShell As Object Dim objWindowsFolder As Object Dim strWindowsFolder As String Dim strWordDocument As String Dim objWordApp As Word.Application Dim objTempDocument As Word.Document Dim objWordDocument As Word.Document Dim objMail As Outlook.MailItem Dim objMailDocument As Word.Document 'Select a Windows Folder Set objShell = CreateObject("Shell.Application") Set objWindowsFolder = objShell.BrowseForFolder(0, "Select a Windows Folder:", 0, "") If Not objWindowsFolder Is Nothing Then strWindowsFolder = objWindowsFolder.self.Path & "\" Set objWordApp = CreateObject("Word.Application") Set objTempDocument = objWordApp.Documents.Add objWordApp.Visible = True 'Merge all Word documents in this folder into one document strWordDocument = Dir(strWindowsFolder & "\*.do*", vbNormal) i = 0 While strWordDocument <> "" i = i + 1 Set objWordRange = objTempDocument.Range With objWordRange .Collapse wdCollapseEnd If i > 1 Then .InsertBreak wdSectionBreakNextPage .End = objTempDocument.Range.End .Collapse wdCollapseEnd End If .InsertFile strWindowsFolder & "\" & strWordDocument End With strWordDocument = Dir() Wend 'Copy the document content into a new Outlook email objTempDocument.Content.Copy Set objMail = Application.CreateItem(olMailItem) Set objMailDocument = objMail.GetInspector.WordEditor objMailDocument.Content.PasteAndFormat (wdFormatOriginalFormatting) objMail.Display objTempDocument.Close False objWordApp.Quit End If End Sub
- After that, press “F5” to run this macro.
- Later, in the new dialog box, select a local folder where the source documents are stored and click “OK”.
- At once, when macro finishes, you will get a new Outlook email, which has all the contents of the source documents in its body.
Fire back against All Threats around Outlook
Outlook file, actually, is as equally vulnerable as Word documents. Hence, it is still an arduous task to protect your Outlook data. In this case, you have to keep all of the potential risks at bay, such as blocking email borne viruses, never clicking the suspicious hyperlinks as well as keeping closing Outlook properly, etc. In addition, it is wise to get hold of a tip-top and proficient Outlook fix utility, like DataNumen Outlook Repair.
Author Introduction:
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair SQL Server and outlook repair software products. For more information visit www.datanumen.com
Leave a Reply