0
我正在嘗試創建一個將電子郵件正文(包含文本和表格)作爲Word.Document傳遞的過程,然後通過電子郵件發送它。但是我無法弄清楚如何將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("[email protected]", "", "Test", WordDoc)
End Sub