VBA Outlook Mail.显示,记录何时/如果手动发送
我的代码显示一条带有基本主题、正文、附件的消息。接下来,用户手动更新和自定义消息并发送它。我想记录电子邮件何时发送。这可能吗?或者有什么提示吗?
我的环境是 Office 2007,带有一个基于 Excel 的宏,用于 Outlook。
[摘抄]
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = Email '.CC =
.Subject = Subj
.BodyFormat = olFormatHTML
.Body = Msg '.HTMLBody = Msg
If Not FileAttach = vbNullString Then .Attachments.Add (FileAttach)
.Display
End With
My code displays a message with basic subject, body, attachment. Next the user manually updates and customizes the message and should send it. I want to record when (if) the email is sent. Is this possible or any tips?
My environment is Office 2007 with an excel based macro going to Outlook.
[Excerpt]
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = Email '.CC =
.Subject = Subj
.BodyFormat = olFormatHTML
.Body = Msg '.HTMLBody = Msg
If Not FileAttach = vbNullString Then .Attachments.Add (FileAttach)
.Display
End With
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过使用 Outlook.MailItem 类中的 _Send 事件,这是完全可能的。
我使用它的方式是创建一个名为 EMail Watcher 的类,因此当我创建电子邮件并执行 .Display 时,我会创建一个新的 EMailWatcher 对象并告诉它监视该电子邮件的发送,然后在发生情况时进行报告。
这是我使用的课程。基本上,我还可以选择设置 BoolRange,以便如果用户发送电子邮件,该 Excel 范围就会更新为 True。我还可以让班级根据发送电子邮件的时间更新 Excel 范围。
这就是我的使用方法:
希望有帮助......
This is entirely possible, using the _Send event in the Outlook.MailItem class.
The way I use it, I create a class called EMail Watcher, so when I create the email and do the .Display, I then create a new EMailWatcher object and tell it to watch that email for send, then report back when it happens.
Here's the class as I use it. Basically, I also optionally can set the BoolRange so that if the user sends the email, that Excel range gets updated with True. I can also have the class update an Excel range with the time the email is sent.
And here's how I use it:
Hopefully that helps...