gpt4 book ai didi

excel - 如何在 VBA 生成的电子邮件正文中添加其他文本/图像?

转载 作者:行者123 更新时间:2023-12-04 20:52:20 32 4
gpt4 key购买 nike

目前,vba 代码创建了一个 Outlook 电子邮件项目,该项目将 Word 文档的内容作为其电子邮件正文。如何向正文添加其他文本/图像?

这个 SO 问题的答案是我如何创建 Outlook 项目:
How to send a Word document as body of an email with VBA

这是我正在使用的实际代码:

Sub email()
Mail_Object, o As Variant

Dim wd As Object, editor As Object
Dim doc As Object
Set wd = CreateObject("Word.Application")
Set doc = wd.documents.Open("(word address)")
doc.Content.Copy
Set wd = Nothing

Set Mail_Object = CreateObject("Outlook.Application")

With Mail_Object.CreateItem(o)
.Subject = "subject"
.To = "to"
Set editor = .GetInspector.WordEditor
editor.Content.Paste

'here something like: body = body & "additional text"
.Display
End With

Application.DisplayAlerts = False
Set Mail_Object = Nothing
End Sub

最佳答案

如果您将对象定义为 .HTMLBody,则可以使用 HTML 标记。您可以尝试执行以下操作:

MailItem.HTMLBody = Content & "<br>" & "<br>"
MailItem.HTMLBody = Content & "<B>" & "<h3>" & "DRAFT: Your Additional Content Here" & "</h3>" & "</B>" & "<br>" & _
"Your Additional Image Here: " & "<br>"& "<img src="image/url">

关于excel - 如何在 VBA 生成的电子邮件正文中添加其他文本/图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56009929/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com