Copy formatted word document to Outlook mail using VBA
Here is a simple snippet that replies to the mail using VBA. The contents of the document has earlier been saved as HTML and the HTML is copied to the mail Item
Public Sub ReplyWithHTML()
Dim oMail As Outlook.MailItem
Dim oFSO
Dim oFS
If Application.ActiveExplorer.Selection.Count Then
If TypeOf Application.ActiveExplorer.Selection(1) Is Outlook.MailItem Then
Set oMail = Application.ActiveExplorer.Selection(1).Reply
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFS = oFSO.OpenTextFile("C:\ForBlogger\formedSample.html")
stext = oFS.readall
oMail.BodyFormat = olFormatHTML
oMail.HTMLBody = stext & vbCr & oMail.HTMLBody
oMail.Display
End If
End If
End Sub
Sunday, May 24, 2009
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.
works great, however if my document has jpg files, they are not displayed. Any tricks
ReplyDeleteyea this is awesome.. how can you then have the replied item moved automatically to a folder.
ReplyDeleteThe code was awesome but I need to reply to more mail in a particular folder.
ReplyDeleteI don't know if you will see this comment but I have been using this effectively for a long time. Doesn't work in Outlook 2016. Have you discovered the same? Is there a solution?
ReplyDelete