vba - 在电子邮件介绍后插入屏幕截图
问题描述
我正在使用下面的代码,它基本上是截取用户表单并将其粘贴到 Outlook 应用程序中。宏工作正常。
我想要实现的是放置一封电子邮件介绍,然后粘贴屏幕截图,但我无法正确执行此操作,因为屏幕截图没有放在文本之后。
这是我的代码
Sub Screenshotemail()
Dim doc As Object, rng As Range
Application.SendKeys "(%{1068})"
DoEvents
'ActiveSheet.Paste
With CreateObject("Outlook.Application").CreateItem(0)
Set doc = .GetInspector.WordEditor
doc.Range(0, 0).Paste
.display
.To = ""
.CC = ""
.Body = "Dear All, " & Chr(10) & Chr(10) & "I kindly remind you that forecasts for program " & Chr(10) & Chr(10) _
& "Please enter your forecast at the link below." _
& Chr(10) & Chr(10) & lien & Chr(10) & Chr(10) & "Best Regards,"
.Subject = "Test:"
.Importance = olImportanceHigh
End With
End Sub
有没有办法让它工作?
解决方案
我的朋友,这需要我几个小时,但我想它有效
只需使用 htmlbody 代替 body,然后在您的消息后连接 htmlbody
参考 在 Outlook 中粘贴表之前写入 - Excel VBA
子截图email()
Dim doc As Object, rng As Range
Dim wdDoc As Object
Dim wdRange As Range
Application.SendKeys "(%{1068})"
DoEvents
Set wdDoc = CreateObject("Word.Application")
'ActiveSheet.Paste
With CreateObject("Outlook.Application").CreateItem(0)
Set doc = .GetInspector.WordEditor
doc.Range(0, 0).Paste
.display
.To = ""
.CC = ""
.htmlbody = "Dear All, " & Chr(10) & Chr(10) & "I kindly remind you that forecasts for program " & Chr(10) & Chr(10) _
& "Please enter your forecast at the link below." _
& Chr(10) & Chr(10) & lien & Chr(10) & Chr(10) & "Best Regards," & .htmlbody
.Subject = "Test:"
.Importance = olImportanceHigh
End With
结束子
推荐阅读
- php - 如何动态设置 Laravel 后备语言环境?
- python - 如何在 Python 中基于另一个数据框填充 NAN 值
- amazon-web-services - 如何让 AWS Batch 一次运行 2 或 3 个以上的作业?
- ruby - MAC - 无法从 https://rubygems.org/ 获取规格
- css - 需要删除列标题 ag-grid 的边框反应
- docker - 如何使 Dockerfile 上的所有环境变量可用?
- azure-logic-apps - Azure 事件网格的新功能 - 尝试对创建、删除或修改的*任何*对象做出反应
- azure - 如果变量不等于 azure 管道 yaml 中的预期值,如何跳过模板?
- perl - 为什么 Web::Scraper 不解析脚本标签?
- python - 它在谈论哪个关键字?( parent = dict(globals or (), **vars) TypeError: 关键字必须是字符串)