Log in

View Full Version : Extracting sub folders from share mailbox



newbie1987
03-31-2020, 07:10 AM
Hello, this is my code. I would like to extract from shared mailbox. How can I apply to call the share mailbox?


Public xlSht As Excel.Worksheet



Sub DocumentFolders(objParent As Folder, lRow As Long)
Dim objItm As Object
Dim objFolder As Folder








On Error Resume Next
With xlSht
For Each objItm In objParent.Items
.Cells(lRow, 1) = objParent
.Cells(lRow, 2) = objItm.Subject
.Cells(lRow, 3) = objItm.ReceivedTime
lRow = lRow + 1
Next
End With
On Error GoTo 0

If objParent.Folders.Count > 0 Then
For Each objFolder In objParent.Folders
Call DocumentFolders(objFolder, lRow)
Next
End If








End Sub








Sub ExportInformation()
Dim xlApp As Excel.Application
Dim xlWb As Excel.Workbook






Set xlApp = New Excel.Application
Set xlWb = xlApp.Workbooks.Add
Set xlSht = xlWb.Sheets(1)

With xlSht
.Cells(1, 1) = "Folder"
.Cells(1, 2) = "Subject"
.Cells(1, 3) = "Received Time"
End With


Call DocumentFolders(Session.GetDefaultFolder(olFolderInbox), 2) '.Folders.Item("testing"), 2)

xlApp.Visible = True








Set xlSht = Nothing
Set xlWb = Nothing
Set xlApp = Nothing








End Sub