这是我的要求。
我在 OUTLOOK 中配置了多个帐户。1) 1@email.com (只有一个邮箱) 2) 2@email.com (有多个邮箱。例如: Unix box, Windows Box, Mac box)
在这里,我的第二个电子邮件帐户有自己的邮箱,并链接到多个邮箱,如 UNIX、Windows 等。每个邮箱都有自己的收件箱和子文件夹。
现在我需要在 Unix 框(收件箱)中选择一个文件夹并运行代码以在该文件夹中执行某些操作。
这就是我所拥有的
For Each oAccount In Application.Session.Accounts
If oaccount ="1@email.com" then
Set folder = ns.GetDefaultFolder(olFolderInbox) ' here it selects the inbox folder of account.
For each item in folder.items
Code goes here
next
end if
next
Run Code Online (Sandbox Code Playgroud)
这对于单个邮箱帐户来说效果很好,但是当我对多个邮箱帐户执行此操作时,它不起作用。
任何帮助,将不胜感激。
您可以使用 的DeliveryStore属性Account来获取其收件箱。例如:
Dim ns As NameSpace
Set ns = Application.Session
Dim acc As Account
Dim f As Folder
For Each acc In ns.Accounts
... Preconditions here ...
Set f = acc.DeliveryStore.GetDefaultFolder(olFolderInbox)
... Now, do some looping ...
Next
Run Code Online (Sandbox Code Playgroud)