【发布时间】:2017-09-19 15:22:22
【问题描述】:
每当我在 Excel 中执行 VBA 代码时,都会生成一封 Outlook 电子邮件。它不会自动发送,我也不希望它自动发送。电子邮件由某个范围内的单元格值填充(基于 ActiveCell),我想以编程方式捕获手动发送电子邮件时到 ActiveCell.Offset(0, 13),最好使用我当前的 Excel 程序中的 VBA。
这是我显示电子邮件的代码:
'Send Stock Request:
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.BodyFormat = olFormatHTML
.HTMLBody = "My eMail's HTML Body"
.To = "myrecipients@theiremails.com"
.CC = ""
.BCC = ""
.Subject = "Stock Request"
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
【问题讨论】:
-
如果在 Excel vba 中不可能(我不知道是否可能),那么也许使用 Outlook vba。有一个发送事件,您可以在其中检查您发送的电子邮件,并将信息存储在 Excel 中。
-
在这种情况下,您知道我将如何访问该活动吗?我熟悉 Excel 的对象模型,但不幸的是不熟悉 Outlook。
-
最后发送邮件时是否保证打开Excel文件?
-
是的,它将在整个过程中打开。