Hack 40 Send a Document as a Plain-Text Outlook Email![]() ![]() Use a macro to turn the text of a Word document into the body of an Outlook email. Sometimes sending a document as an email attachment is overkill, especially if you just want the recipient to review the text of a simple document. And if the recipient is under a particularly restrictive mail server, he may not be able to receive Word document attachments, for fear of a virus. Now, you can always try to cut and paste the text into the body of an email, but that rarely produces anything better than a giant block of continuous text that can be difficult to read from an email window. Another option is to save the document as a plain-text .txt file, open up that file in a text editor such as Notepad, add some extra line breaks for readability, then cut and paste that into an email. Yuck. Here's an easier option: after changing a few settings from within the Visual Basic Editor, you can write macros that directly access Outlook from within Word, let you get the text-only contents of a document, add some extra line breaks for readability, quickly create a new email message, and insert the text as the message body. 4.15.1 Setting the Reference to OutlookFirst, make sure you can access the Outlook object model from within Word. Select Tools choose Tools "Microsoft Outlook 11.0 Object Library" box, as shown in Figure 4-21.
Figure 4-21. Setting a reference to the Outlook object model![]() Once you've established that reference, you can access the Outlook object model from your Word macros. 4.15.2 The CodePlace this macro in the template of your choice [Hack #50] and either run it from the Tools dialog or put a button for it on a menu or toolbar [Hack #1]. Since there's a good chance Outlook may already be open when running a macro that accesses it, the code first tries to reference the currently open instance of Outlook. If it can't find one, the code creates and uses a new instance of Outlook. Sub doc2outlookemail( ) The code leaves the email open and unaddressed. Just fill in the recipient's address and click the Send button. 4.15.3 Hacking the HackRather than sending the entire contents of a Word document, you may want to send just the outline as a plain-text email. To do so, first switch to Outline view in your document and select the outline level you want included in the email. Only the text visible from Outline view will be included in the email. Now make a minor adjustment to the earlier macro, as shown in bold: Sub SendOutlineOnly( ) |