PDA

View Full Version : Sleeper: Excel Macro - Word doc as message body images



rmsagar
08-31-2010, 09:33 PM
I am a beginner, please pardon my ignorance
I have an excel sheet contains email address and I have a word document (Contains Images) which I would be using it as the message body. To begin with I tried this code it is able to put the word contents in the body but the images are missing. Any thoughts/advice please ?


Sub SendOutlookMessages()
'Dimension variables.
Dim OL As Object, MailSendItem As Object
Dim W As Object
Dim MsgTxt As String, SendFile As String
Dim ToRangeCounter As Variant
'Identifies Word file to send
SendFile = Application.GetOpenFilename(Title:="Select MS Word " & _
"file to mail, then click 'Open'", buttontext:="Send", _
MultiSelect:=False)
'Starts Word session
Set W = GetObject(SendFile)
'Pulls text from file for message body
MsgTxt = W.Range(Start:=W.Paragraphs(1).Range.Start, _
End:=W.Paragraphs(W.Paragraphs.Count).Range.End)
'Ends Word session
Set W = Nothing
'Starts Outlook session
Set OL = CreateObject("Outlook.Application")
Set MailSendItem = OL.CreateItem(olMailItem)
ToRangeCounter = 0
'Creates message
With MailSendItem
.Body = MsgTxt
.Attachments.Add "c:\test.docx"
.To = "sample@sam.com"
.Display
End With
'Ends Outlook session
Set OL = Nothing
End Sub