[英]Event listener for inbox of second account
我正在尝试创建一个事件监听器:
我尝试了类似的东西:
For Each oAccount In Application.Session.Accounts
If oAccount = "fakeemail@outlook.com" Then
您需要通过Application.Session.Folders按文件夹名称访问您的第二个帐户
GetDefaultFolder不适用于其他商店或邮箱。
或者您可以使用For Each oAccount In Application.Session.Accounts
来获取GetDefaultFolder ,但如果您已经知道帐户名fakeemail@outlook.com
,则不要使用它。
例子
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olNs As Outlook.NameSpace
Dim Inbox As Outlook.Folder
Set olNs = Application.GetNamespace("MAPI")
Set Inbox = olNs.Folders("fakeemail@outlook.com") _
.Folders("Inbox")
Set Items = Inbox.Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.mailitem Then
Debug.Print Item.Subject
End If
End Sub
仅供参考代码转到ThisOutlookSession
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.