When finishing editing the body of an email in Outlook, some users wish to convert the body to an attachment, such as TXT or Doc attachment. Hence, in this article, we will introduce you a method to quickly realize it.
After you compose an email, if email body is too long, you may wish to attach a copy of body to the email. In general, you have to create a new file. Then, you can copy the email body to the file and next attach the file. It is a bit cumbersome. Hence, in the followings, we’ll introduce a quicker way.
Attach a Copy of the Body to the Email when Composing It
- At the very outset, launch Outlook VBA editor via “Alt + F11”.
- Then, in “Microsoft Visual Basic for Applications” window, enable “MS Word Object Library” as per “How to Add an Object Library Reference in VBA“.
- Next, copy the following code into a module or project.
Sub ConvertEmailBodyToTXTAttachment() Dim objCurrentMail As Outlook.MailItem Dim strTextFile As String Dim objFileSystem As Object Dim objTextFile As Object Set objCurrentMail = Outlook.Application.ActiveInspector.CurrentItem If objCurrentMail.Subject <> "" Then strTextFile = "E:\" & objCurrentMail.Subject & ".txt" Else strTextFile = "E:\Email Body.txt" End If 'Create a Text file Set objFileSystem = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFileSystem.CreateTextFile(strTextFile, True) objTextFile.WriteLine (objCurrentMail.Body) objTextFile.Close objCurrentMail.Attachments.Add strTextFile objFileSystem.DeleteFile strTextFile End Sub Sub ConvertEmailBodyToDOCAttachment() Dim objCurrentMail As Outlook.MailItem Dim objMailDocument As Word.Document Dim objWordApp As Word.Application Dim objWordDocument As Word.Document Dim strWordDocument As String Set objCurrentMail = Outlook.Application.ActiveInspector.CurrentItem Set objMailDocument = objCurrentMail.GetInspector.WordEditor objMailDocument.Application.Selection.WholeStory objMailDocument.Application.Selection.Copy 'Create a Word Document Set objWordApp = CreateObject("Word.Application") objWordApp.Visible = True Set objWordDocument = objWordApp.Documents.Add objWordDocument.Range(0, 0).PasteAndFormat wdFormatOriginalFormatting If objCurrentMail.Subject <> "" Then strWordDocument = "E:\" & objCurrentMail.Subject & ".doc" Else strWordDocument = "E:\Email Body.doc" End If objWordDocument.SaveAs2 strWordDocument objWordDocument.Close True objWordApp.Quit objCurrentMail.Attachments.Add strWordDocument Kill strWordDocument End Sub
- After that, exit the VBA editor.
- Later, follow the “Optional Step” introduced in “How to Run VBA Code in Your Outlook” to add the two macros to the ribbon of Message window.
- Finally, create a new mail, compose the mail body and click the macro button.
- If you click “Body to TXT” macro button, the body will be converted to a text file attachment.
- If you click “Body to DOC” macro button, the body will be converted to a Word document attachment.
Don’t Fear Outlook Crash
Has your Outlook ever crashed? Most of users are afraid of it since it can directly result in Outlook data corruption. Nevertheless, if you insist on backing up your Outlook PST files on a regular basis, you don’t need to fear Outlook crash in that even if PST file is corrupt, you can easily recover Outlook data from backups. In addition, if backup is not help, you still can apply a remarkable recovery tool, like DataNumen Outlook Repair.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including mdf repair and outlook repair software products. For more information visit www.datanumen.com