我试图弄清楚如何通过在该文件夹上放置一个侦听器来跟踪进入该文件夹的邮件项目的数量,但它无法正常工作。这就是我所拥有的,但由于某种原因,当我将多封电子邮件拖到该文件夹时,所选数量不正确。基本上,我要对文件夹执行的操作是将拖入其中的邮件项目的所有名称更改为相同的名称。所以我需要能够有一种方法来引用那些被拖入的项目。我想我可以通过使用选择来做到这一点,但我不确定。有任何想法吗??谢谢!这是我的代码:
Private WithEvents MatchTicketNumberItems As Outlook.Items
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
'Specify folders that will have listeners on them
Set MatchTicketNumberItems = objNS.GetDefaultFolder(olFolderInbox).Parent.Folders("MatchTicketNumber").Items
End Sub
Private Sub MatchTicketNumberItems_ItemAdd(ByVal item As Object)
Dim selected As Integer
Dim objSelection As Outlook.Selection
Set objSelection = Application.ActiveExplorer.Selection
selected = objSelection.count
'Do stuff
End Sub