按类别获取公用文件夹中的项目数 [英] Get count of items in public folder by category
问题描述
我正在尝试按类别获取文件夹中的项目数。我无法弄清楚如何轻松地做到这一点。我能够返回文件夹中每个项目的类别,但是由于冲突的项目,我会收到自动化错误。我试图计算
如何跳过这些但是无法做到。下面是我在Excel中用VBA编写的代码。
I'm trying to get the count of items in a folder by category. I'm unable to figure out how to do this easily. I was able to return the category for each item in a folder however I would get an automation error due to items in conflict. I tried to figure out how to skip over these but was unable to. Below is my code written in VBA from Excel.
我正在编写每个类别和项目的主题,以便我可以确定为什么我收到自动化错误。这是我遇到邮件项冲突的时候。
I was writing each category and item subject to a sheet so that i could identify why i was getting an automation error. This is when I encountered the mail item conflict.
Sub Outlook()
Dim objOL As Outlook.Application
Dim objCat As Outlook.Category
Dim subFolder As Outlook.Folder
Dim mailItems As Items
Dim mailItem As Object
Dim mailItemConflicts As Conflict
Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders.Item("Authorization")
i = 1
For Each subFolder In objFolder.Folders
Set mailItems = subFolder.Items
' MsgBox (subFolder.Name)
' MsgBox (mailItems.Count)
For Each mailItem In mailItems
Worksheets("Sheet1").Range("B" & i).Value = mailItem.Subject
Worksheets("Sheet1").Range("A" & i).Value = mailItem.Categories
i = i + 1
End If
Next
Next
End Sub
推荐答案
您好,
>>但由于项目存在冲突,我会收到自动化错误。
>>however I would get an automation error due to items in conflict.
您是否有权访问公用文件夹?什么是错误乱七八糟?你会得到哪一行和哪一项错误?
Do you have permission to access the public folder? What is the error messgae? Which line and which item would you get the error?
你的意思是什么?您能否分享一下重现问题的详细步骤?请分享我们如何创建冲突项目。
What conflict do you mean? Could you please share detail steps to reproduce the issue? Please share us how we could create a item in conflict.
问候。
Celeste
这篇关于按类别获取公用文件夹中的项目数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!