I'm sending emails from Excel using a Word doc as the email body via Outlook, this works.
My problem is that an image used as a signature in the word doc is stripped out in the final message.
This is the current macro code to get the word doc into Outlook.
Sub Create_Mail_From_List_Orders_Collection(Target As Range)
'Setup Outlook
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
'Setup word
Dim wd As Word.Application
Dim doc As Word.Document
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
'Get the word document
Set wd = CreateObject("Word.Application")
wd.Visible = True
Set doc = Documents.Open(Filename:="J:\AutoSend Emails\Collections.doc", ReadOnly:=True)
'Copy the open document
doc.Content.Select
Word.Selection.Copy
'Setup the email
.To = Target.Value
.Subject = "Collecting"
.Body = Word.Selection
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
cleanup:
doc.Close
wd.Quit
Set doc = Nothing
Set OutApp = Nothing
Set wd = Nothing
Application.ScreenUpdating = True
End Sub
I have come across this code that suggests copy and paste for the doc content as a solution, but can't integrate the concept into my macro to make it work. Could you help please.
Sub emailFromDoc()
Dim wd As Object, editor As Object
Dim doc As Object
Dim oMail As MailItem
Set wd = CreateObject("Word.Application")
Set doc = wd.documents.Open(...path to your doc...)
doc.Content.Copy
doc.Close
set wd = Nothing
Set oMail = Application.CreateItem(olMailItem)
With oMail
.BodyFormat = olFormatRichText
Set editor = .GetInspector.WordEditor
editor.Content.Paste
.Display
End With
End Sub
Bookmarks