我在Outlook中写了一些vba,当新的电子邮件进来时会触发。但是我想在一封旧的电子邮件中将其解雇以进行测试。任何人都可以告诉我如何。
我目前的代码是
Private Sub objInbox_ItemAdd(ByVal Item As Object)
由于
答案 0 :(得分:0)
我已经把它整理好了。
Private Sub Application_Startup()
Set objInbox = Session.GetDefaultFolder(olFolderInbox).Items
'Call test
'MsgBox "outlook starting"
End Sub
Sub test()
MsgBox "in test"
Dim ns As NameSpace
Dim item As Object
Dim inbox As MAPIFolder
'Dim sub_folder As MAPIFolder
Set ns = GetNamespace("MAPI")
Set inbox = ns.GetDefaultFolder(olFolderInbox)
'Set sub_folder = inbox.Folders("TEST")
For Each item In inbox.Items
If TypeOf item Is MailItem Then
MsgBox "right subject"
End If
Next item
End Sub