在电子邮件正文中插入Word.Document?(Insert Word.Document in email body?)

编程入门 行业动态 更新时间:2024-10-24 22:20:51
在电子邮件正文中插入Word.Document?(Insert Word.Document in email body?)

我正在尝试创建一个过程,将一个电子邮件正文(带有文本和表格)作为Word.Document传递,然后通过电子邮件发送。 但是,我无法弄清楚如何将Word.Document插入电子邮件正文。

这就是我现在正在尝试的事情:

Sub CreateDraft(Destinatary As String, CC As String, Subject As String, Body As Word.Document) Dim OutApp As New Outlook.Application Dim OutMail As Outlook.MailItem Dim OutInspector As Outlook.Inspector Dim WordDoc As Word.Document Set OutMail = OutApp.CreateItem(olMailItem) With OutMail .To = Destinatary .CC = CC .Subject = Subject .Display Set OutInspector = OutMail.GetInspector Set WordDoc = OutInspector.WordEditor ' How do I insert the Body object to the email? Call .Save Call .Close(False) End With End Sub Sub SendButton_Click() Dim WordApp As New Word.Application Dim WordDoc As Word.Document Set WordDoc = WordApp.Documents.Add WordApp.Visible = False ThisWorkbook.Sheets(1).Range("A1:E10").Copy WordApp.Selection.PasteExcelTable False, False, False Call CreateDraft("abc@example.com", "", "Test", WordDoc) End Sub

I'm trying to create a procedure that is passed an email body (with text and tables) as a Word.Document and then sends it in an email. However I can't figure out how to insert the Word.Document to the email body.

This is what I'm trying now:

Sub CreateDraft(Destinatary As String, CC As String, Subject As String, Body As Word.Document) Dim OutApp As New Outlook.Application Dim OutMail As Outlook.MailItem Dim OutInspector As Outlook.Inspector Dim WordDoc As Word.Document Set OutMail = OutApp.CreateItem(olMailItem) With OutMail .To = Destinatary .CC = CC .Subject = Subject .Display Set OutInspector = OutMail.GetInspector Set WordDoc = OutInspector.WordEditor ' How do I insert the Body object to the email? Call .Save Call .Close(False) End With End Sub Sub SendButton_Click() Dim WordApp As New Word.Application Dim WordDoc As Word.Document Set WordDoc = WordApp.Documents.Add WordApp.Visible = False ThisWorkbook.Sheets(1).Range("A1:E10").Copy WordApp.Selection.PasteExcelTable False, False, False Call CreateDraft("abc@example.com", "", "Test", WordDoc) End Sub

最满意答案

Word对象模型提供了复制和粘贴方法。 有关更多信息,请参见第17章:使用项目实体 。

The Word object model provides the Copy and Paste methods. See Chapter 17: Working with Item Bodies for more information.

更多推荐

本文发布于:2023-04-29 03:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334573.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文中   电子邮件   Word   Document   email

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!