Outlook-Kategorien zählen für Shared Mailbox

341
Craig

Ich versuche, die Anzahl der Elemente zu ermitteln, die einer Kategorie in einem freigegebenen Postfach zugeordnet sind, das mit meinem Outlook-Konto verknüpft ist. Der gesamte Code, den ich gefunden habe, bezieht sich nur auf die tatsächlichen Outlook-Kategorien. Ich bin nicht sicher, wie das Element so eingestellt wird, dass es das freigegebene Postfach anzeigt, damit die Kategorien gezählt werden. Ich glaube, das Problem ist der Code in Fettdruck unten, aber ich kann keine Eigenschaft finden, die auf die gemeinsam genutzte Mailbox verweist.

Ich habe diesen Code ein wenig an meine Bedürfnisse angepasst, aber er wurde von Shirley Zhang geschrieben:

 Public objDictionary As Object Public objExcelApp As Excel.Application Public objExcelWorkbook As Excel.Workbook Public objExcelWorksheet As Excel.Worksheet  Sub ExportCountofItemsinEachColorCategories() Dim objCategories As Object Dim objCategory As Object Dim objPSTFile As Outlook.Folder Dim objFolder As Outlook.Folder Dim strExcelFile As String  'Create a New Excel file Set objExcelApp = CreateObject("Excel.Application") Set objExcelWorkbook = objExcelApp.Workbooks.Add Set objExcelWorksheet = objExcelWorkbook.Sheets("Sheet1") objExcelWorksheet.Cells(1, 1) = "Color Category" objExcelWorksheet.Cells(1, 2) = "Count"  'Find all the color categories Set objDictionary = CreateObject("Scripting.Dictionary")  'I believe the error is here vvv Set objCategories = Outlook.Application.Session.Categories For Each objCategory In objCategories objDictionary.Add objCategory.Name, 0 Next  Set objPSTFile = Outlook.Application.Session.PickFolder  For Each objFolder In objPSTFile.Folders ProcessFolder objFolder Next  'Save the new Excel file objExcelWorksheet.Columns("A:B").AutoFit strExcelFile = "C:\Users\cdlane\Documents\Color Categories (" & Format(Now, "yyyy-mm-dd_hh-mm-ss") & ").xlsx" objExcelWorkbook.Close True, strExcelFile   MsgBox "Complete!", vbExclamation End Sub 
0

1 Antwort auf die Frage

0
niton
Sub CategoriesByStore()  Dim colStores As Stores Dim oStore As store Dim objCategories As Categories Dim objCategory As Category Dim i As Long  Set colStores = Session.Stores  ' Debug.Print "colStores.count: " & colStores.count  For i = 1 To colStores.count  Set oStore = colStores(i) Debug.Print "Store " & i & ": " & oStore  If oStore = "store name from immediate window" Then  Set objCategories = oStore.Categories For Each objCategory In objCategories Debug.Print objCategory Next  Exit For  End If  Next  End Sub