admin管理员组文章数量:1391987
I have several Word files and I want to send them as an email template (one after another) to the partners
I've used the following code:
Dim filePath As String
filePath = "locally stored file" & partnerName & ".docx"
wordDoc.SaveAs2 filePath
wordDoc.Content.Copy
Dim dataObj As Object
Set dataObj = CreateObject("MSForms.DataObject")
dataObj.GetFromClipboard
wordContent = dataObj.GetText(1)
wordDoc.Close
emailAddress = ws.Cells(i + 1, 12).Value
Set outlookMail = outlookApp.CreateItem(0)
With outlookMail
.To = emailAddress
.Subject = "FY25 Reward results for Q3 FY25: " & partnerName
.HTMLBody = wordContent
.Send
End With
Next i
Here I am not getting an error, but the content is sent as a plain text to the recipient.
In my word template, I've images, tables, links, and other formatted text. I want to send the doc as is. Preserving the formatted nature.
Thanks in advance!
I have several Word files and I want to send them as an email template (one after another) to the partners
I've used the following code:
Dim filePath As String
filePath = "locally stored file" & partnerName & ".docx"
wordDoc.SaveAs2 filePath
wordDoc.Content.Copy
Dim dataObj As Object
Set dataObj = CreateObject("MSForms.DataObject")
dataObj.GetFromClipboard
wordContent = dataObj.GetText(1)
wordDoc.Close
emailAddress = ws.Cells(i + 1, 12).Value
Set outlookMail = outlookApp.CreateItem(0)
With outlookMail
.To = emailAddress
.Subject = "FY25 Reward results for Q3 FY25: " & partnerName
.HTMLBody = wordContent
.Send
End With
Next i
Here I am not getting an error, but the content is sent as a plain text to the recipient.
In my word template, I've images, tables, links, and other formatted text. I want to send the doc as is. Preserving the formatted nature.
Thanks in advance!
Share Improve this question edited Mar 15 at 17:03 braX 11.8k5 gold badges22 silver badges37 bronze badges asked Mar 15 at 8:00 Shreeuday KasatShreeuday Kasat 34 bronze badges 01 Answer
Reset to default 1I think your call Clipboard calls are getting plain text out of Word ... but Outlook will need HTML.
This (very old) thread has the same question. Solution there uses VB to save/convert the doc to HTML, then send a copy of that HTML to Outlook. I expect this is the route you will need to go:
https://www.experts-exchange/questions/23606380/Copy-Word-Doc-to-Body-of-Email.html
Ah, same one here, also:
How to send a Word document as body of an email with VBA
本文标签: excelWord template as an email body and sending emailStack Overflow
版权声明:本文标题:excel - Word template as an email body and sending email - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744620974a2616020.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论