【发布时间】:2014-02-24 20:06:36
【问题描述】:
我正在尝试寻找一种方法来从 Access 中捕获 Outlook 中的 MailItem.Send 事件。我创建了一个类来设置对象并且工作正常,但事件处理程序似乎没有做任何事情。
这是我创建的类(命名为OutlookHandler):
Public WithEvents app As Outlook.Application
Public WithEvents msg As Outlook.MailItem
Private Sub Class_Initialize()
Set app = CreateObject("Outlook.Application")
Set msg = app.CreateItem(olMailItem)
End Sub
Private Sub msg_Send(Cancel As Boolean)
MsgBox "Message Sent!"
End Sub
这是我创建该类实例的函数:
Public Function test()
Dim ol As New OutlookHandler
With ol.msg
.To = "mike@anywhere.com"
.Subject = "outlook event test"
.Display
End With
End Function
当我运行test 时,电子邮件会创建并显示。当我在电子邮件中点击发送时,电子邮件发送但消息框永远不会创建。我错过了什么?
【问题讨论】: