

#Excel macro to create outlook email with text in email body how to

Text to add: How to arrange it properly.Images to insert: How to get a link that will work.for our smart Shared Email Templates add-in :) Just a few steps to take, and a dynamic Outlook template for your team will be ready. So, when the template is going to be pasted into the email body by another person, all this stuff should change automatically.ĭo you think that such a task is too difficult? Nothing of the kind. The problem is that each of your colleagues would like to get a different image, an individual attachment, and some specific text added to the template every time they use it. Let's say, you have a really nice template, and your teammates would be happy to use it in their correspondence, but you're stuck on making this template dynamic. Set ts = fso.GetFile(TempFile).On reading this blog post, you'll learn how to automatically switch images, attachments, and text in a shared Outlook template, depending on the current user. Paste method from the Word object model for pasting the data in the message body automatically. Note, you can Copy the required range in Excel and then use the But the Body property will not help you because you need to preserve colors (keep the markup as is). It us up to you which way is to choose to customize the message body. You can read more about all these ways in the Chapter 17: Working with Itemīodies. The WordEditor property of the Inspector class returns an instance of the Document class from the Word object model which you can use to set up the message body. The Microsoft Word Document Object Model of the message being displayed. The Outlook object model provides three main ways for working with item bodies:Ī string representing the clear-text body of the Outlook item.Ī string representing the HTML body of the specified item. See How to automate Outlook from another program for more information. Looks like you need to automate Outlook from Excel VBA. Here to refer about OfficeTalk: Using the Excel Object Model to Send Workbooks and Ranges through E-Mail with Outlook RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _ Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2) Set fso = CreateObject("Scripting.FileSystemObject")


htm file into the RangetoHTML subroutine. Source:=TempWB.Sheets(1).UsedRange.Address, _ Cells(1).PasteSpecial xlPasteFormats,, False, False Cells(1).PasteSpecial xlPasteValues,, False, False ' Copy the range and create a workbook to receive the data. Set OutApp = CreateObject("Outlook.Application") So pleaseĪccording to your description, I have made a sample to let you refer to: Sub SendMail() I can send mail from outlook through Excel VBA but never like this. Range (A1:I12)) as mail body (not as attachment) including color of the row and column with same format (like a image of that range).
