kdunnett
asked on
Generating a list of entryids under the "all Public Folders" tree
I require a way of generating a list of all entryids with folder name and path for all folders listed under the "all Public Folders" tree from outlook to a file. Does anybody have a tool or a piece of code to do this???
Regards...
Regards...
ASKER
Excellent example, any instructions you have would be great as I’m new to outlook.
Thanks....
Thanks....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks man this is excellent
You're welcome.
ASKER
Is there a way I could add the size of the outlook public folder to the log file using the above code?
objFile.WriteLine .EntryID & vbTab & Pad(.Name, 25) & .FolderPath & vbTab & <FOLDER SIZE>
objFile.WriteLine .EntryID & vbTab & Pad(.Name, 25) & .FolderPath & vbTab & <FOLDER SIZE>
The Folder object doesn't have a size property. The only way to calculate the size would be to loop through all the items in the folder and add the size up.
ASKER
BlueDevilFan
If I was to create a new question could you come up with some code to return the size of each folder
Thanks
If I was to create a new question could you come up with some code to return the size of each folder
Thanks
Sure.
This will do it. Let me know if you need instuctions on how to run this from inside Outlook.
'Code Begins Here
Dim objFSO As Object, _
objFile As Object
Sub DumpEntryIDs()
Set objFSO = CreateObject("Scripting.Fi
'Change the file name and path on the following line
Set objFile = objFSO.CreateTextFile("C:\
ProcessFolder OpenMAPIFolder("\Public Folders\All Public Folders")
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
MsgBox "All done!"
End Sub
Sub ProcessFolder(olkFolder As Outlook.MAPIFolder)
Dim olkSubFolder As Outlook.MAPIFolder
With olkFolder
objFile.WriteLine .EntryID & vbTab & Pad(.Name, 25) & .FolderPath
End With
For Each olkSubFolder In olkFolder.Folders
ProcessFolder olkSubFolder
Next
Set olkSubFolder = Nothing
End Sub
Function Pad(strValue As String, intLength As Integer) As String
Dim intValueLength As Integer
intValueLength = Len(Trim(strValue))
If intValueLength < intLength Then
Pad = Trim(strValue) & Space(intLength - intValueLength)
Else
Pad = strValue
End If
End Function
'Credit where credit is due.
'The code below is not mine. I found it somewhere on the internet but do
'not remember where or who the author is. The original author(s) deserves all
'the credit for these functions.
Function OpenMAPIFolder(szPath)
Dim app, ns, flr, szDir, i
Set flr = Nothing
Set app = CreateObject("Outlook.Appl
If Left(szPath, Len("\")) = "\" Then
szPath = Mid(szPath, Len("\") + 1)
Else
Set flr = app.ActiveExplorer.Current
End If
While szPath <> ""
i = InStr(szPath, "\")
If i Then
szDir = Left(szPath, i - 1)
szPath = Mid(szPath, i + Len("\"))
Else
szDir = szPath
szPath = ""
End If
If IsNothing(flr) Then
Set ns = app.GetNamespace("MAPI")
Set flr = ns.Folders(szDir)
Else
Set flr = flr.Folders(szDir)
End If
Wend
Set OpenMAPIFolder = flr
End Function
Function IsNothing(obj)
If TypeName(obj) = "Nothing" Then
IsNothing = True
Else
IsNothing = False
End If
End Function
'Code Ends Here
Cheers!