我正在寻找一种获取Outlook中移动项目/电子邮件事件的方法。
我们可以使用检查器吗?或者可能有像itemsent或newmail这样的事件处理程序吗?
谢谢。
更多细节:
我有4个或更多的邮箱。每个邮箱都有X个文件夹和子文件夹(其中一个是具有数百万个文件夹的livelink邮箱)。有些是公共邮箱,有人会拖动公共邮件。
我想捕获每次在livelink邮箱中将邮件移动到文件夹中的情况。
我正在寻找一种获取Outlook中移动项目/电子邮件事件的方法。
我们可以使用检查器吗?或者可能有像itemsent或newmail这样的事件处理程序吗?
谢谢。
更多细节:
我有4个或更多的邮箱。每个邮箱都有X个文件夹和子文件夹(其中一个是具有数百万个文件夹的livelink邮箱)。有些是公共邮箱,有人会拖动公共邮件。
我想捕获每次在livelink邮箱中将邮件移动到文件夹中的情况。
当在文件夹中添加一个项目时,会触发事件。例如,假设您的默认收件箱下面有一个名为“Stuff”的文件夹。每次将电子邮件移动到该文件夹时,此代码都会触发:
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Set olApp = Outlook.Application
Set Items = GetNS(olApp).GetDefaultFolder(olFolderInbox).Folders("Stuff").Items
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
On Error GoTo ErrorHandler
MsgBox "You moved an item into the 'Stuff' folder."
ProgramExit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ProgramExit
End Sub
Function GetNS(ByRef app As Outlook.Application) As Outlook.NameSpace
Set GetNS = app.GetNamespace("MAPI")
End Function