How to Export all Messages from MS Outlook into CSV file using PowerShell?

%3CLINGO-SUB%20id%3D%22lingo-sub-2094329%22%20slang%3D%22en-US%22%3EHow%20to%20Export%20all%20Messages%20from%20MS%20Outlook%20into%20CSV%20file%20using%20PowerShell%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2094329%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Guys%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20are%20you%20guys%20doing%20today%3F%20I%20am%20still%20new%20to%20Powershell%20and%20keep%20on%20learning%20it%20every%20day.%20I%20need%20some%20helps%20here%2C%20I%20need%20to%20export%20all%20MS%20Outlook%20messages%20to%20CSV%20files.%20I%20know%20this%20is%20easy%20for%20some%20of%20you%20guys.%20Here%20is%20my%20requirements%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%20Read%20all%20folders%20in%20MS%20Outlook%20in%20local%20system.%3CBR%20%2F%3E2.%20Display%20the%20Outlook%20folder%20path%20that%20contain%20the%20messages.%3C%2FP%3E%3CP%3E3.%20Count%20number%20of%20messages%20in%20each%20folder.%3CBR%20%2F%3E4.%20If%20folder%20got%20messages%2C%20then%20export%20the%20message%20items%20with%20this%20properties%20(SenderName%2C%20To%2C%20SentOn%2C%20ReceivedTime%2C%20Body)%20to%20a%20CSV%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CU%3EHere%20is%20what%20I%20got%20so%20far%3A%3C%2FU%3E%3C%2FP%3E%3CP%3E1.%20I%20managed%20to%20connect%20to%20the%20current%20MS%20Outlook%20session%20using%20Powershell.%3C%2FP%3E%3CP%3E2.%20I%20can%26nbsp%3Biterate%20all%20the%20Outlook%20folders%20and%20count%20number%20of%20message%20items%20in%20each%20folders.%3C%2FP%3E%3CP%3E3.%20Create%20the%20CSV%20output%20files%20to%20hold%20the%20messages.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%20I%20got%20%3CSTRONG%3Ezero%3C%2FSTRONG%3E%20content%20for%20my%20CSV%20output.%20I%20am%20having%20problem%20to%20get%20the%20Messages%20item%20properties%20from%20the%20OutlookNameSpace.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20know%20we%20can%20do%20it%20like%20below%20to%20get%20the%20properties%20out%20to%20CSV%20files%2C%20but%20how%20can%20I%20use%20it%20in%20my%20code%20because%20the%20Outlook%20folders%20name%20are%20dynamic%20%3F%3C%2FP%3E%3CP%3EPS%20C%3A%5CWorkDev%20%26gt%3B%20%24OutlookNameSpace.Folders.Item(%22Personal_PST%22).Folders.Item(%22UserName1%22).Folders.Item(%22Subfolder2.2%22).Folders.Item(%22Subfolder3.1%22).Items.count%3CBR%20%2F%3E6%3C%2FP%3E%3CP%3EPS%20C%3A%5CWorkDev%20%26gt%3B%20%24OutlookNameSpace.Folders.Item(2).Folders.Item(2).Folders.Item(2).Folders.Item(1).Items.count%3CBR%20%2F%3E6%3C%2FP%3E%3CP%3EPS%20C%3A%5CWorkDev%20%26gt%3B%20%24OutlookNameSpace.Folders.Item(2).Folders.Item(2).Folders.Item(2).Folders.Item(1).Items%20%7C%20Select-Object%20-Property%20SenderName%2C%20To%2C%20SentOn%2C%20ReceivedTime%2C%20Body%20%7C%20Export-Csv%20-Path%20CSV_OutputFile.csv%20-NoTypeInformation%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20anybody%20advice%20me%20on%20how%20to%20make%20this%20works%3F%20Thank%20you%20very%20much%20in%20advance.%20I%20really%20appreciate%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ECode%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EFunction%20Main%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%23Clear%20console%20screen%3CBR%20%2F%3EClear-Host%3CBR%20%2F%3E%3CBR%20%2F%3EWrite-Host%20%22PS%20Script%20Start!%20%60n%22%3CBR%20%2F%3E%3CBR%20%2F%3E%23%20Import%20assembly%20files%3CBR%20%2F%3EAdd-Type%20-assembly%20%22Microsoft.Office.Interop.Outlook%22%3C%2FP%3E%3CP%3E%23%20This%20creates%20a%20new%20COM%20(Component%20Object%20Model)%20Object%20to%20access%20Outlook%20with.%3CBR%20%2F%3E%24Outlook%20%3D%20New-Object%20-ComObject%20Outlook.Application%3C%2FP%3E%3CP%3E%23%20Map%20MAPI%20GetNameSpace%20to%20OutlookNameSpace%3CBR%20%2F%3E%24OutlookNameSpace%20%3D%20%24Outlook.GetNameSpace(%22MAPI%22)%3C%2FP%3E%3CP%3E%23%20Iterate%20through%20all%20Outlook%20folders%3CBR%20%2F%3Eforeach%20(%24folder%20in%20%24OutlookNameSpace.Folders)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20Get-MailboxFolder%20%24folder%3CBR%20%2F%3E%7D%3CBR%20%2F%3EWrite-Host%20%22%60nPS%20Script%20End!%22%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3EFunction%20Get-MailboxFolder(%24OutlookFolder)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%23Get%20current%20date%20and%20time%3CBR%20%2F%3E%24GetCurrentDateTime%20%3D%20(Get-Date%20-format%20%22yyyyMMddHHmmss_UTCzz%22)%3C%2FP%3E%3CP%3Eforeach%20(%24f%20in%20%24OutlookFolder.Folders)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Get-MailboxFolder%20%24f%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%23If%20%24OutlookFolder.Items.Count%20!%3D%200%3CBR%20%2F%3Eif(%24OutlookFolder.items.count%20-ne%200)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%24OutlookFolderPath%20%3D%20%24OutlookFolder.FolderPath%3CBR%20%2F%3E%24OutlookFolderName%20%3D%20%24OutlookFolder.name%3CBR%20%2F%3E%24OutlookFolderItemsCount%20%3D%20%24OutlookFolder.items.count%3CBR%20%2F%3E%24ExportOutlookMessage%20%3D%20%24OutlookFolder.Folders.items%3CBR%20%2F%3E%3CBR%20%2F%3E%23%20Create%20the%20CSV%20output%20file%3CBR%20%2F%3E%24CSV_OutputFile%20%3D%20%22OutFile_%22%2B%24OutlookFolderName%2B%22_%22%2B%24GetCurrentDateTime%2B%22.csv%22%3CBR%20%2F%3E%24ExportOutlookMessage%20%7C%20Select-Object%20-Property%20SenderName%2C%20To%2C%20SentOn%2C%20ReceivedTime%2C%20Body%20%7C%20Export-Csv%20-Path%20%24CSV_OutputFile%20-NoTypeInformation%3CBR%20%2F%3E%3CBR%20%2F%3EWrite-Host%20%22Outlook%20Folder%20Path%3A%20%24OutlookFolderPath%22%3CBR%20%2F%3EWrite-Host%20%22Outlook%20Message%20Count%3A%20%24OutlookFolderItemsCount%22%3CBR%20%2F%3EWrite-Host%20%22CSV%20File%20Output%3A%20%24CSV_OutputFile%20%60n%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E.%20Main%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EHere%20is%20my%20script%20run%20output%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EPS%20Script%20Start!%3C%2FP%3E%3CP%3EOutlook%20Folder%20Path%3A%20%5C%5CPersonal_PST%5CUserName1%5CSubfolder2.4%3CBR%20%2F%3EOutlook%20Message%20Count%3A%20110%3CBR%20%2F%3ECSV%20File%20Output%3A%20OutFile_Subfolder2.4_20210125223011_UTC-06.csv%3C%2FP%3E%3CP%3EOutlook%20Folder%20Path%3A%20%5C%5CPersonal_PST%5CUserName1%5CSubfolder2.2%5CSubfolder3.1%3CBR%20%2F%3EOutlook%20Message%20Count%3A%206%3CBR%20%2F%3ECSV%20File%20Output%3A%20OutFile_Subfolder3.1_20210125223011_UTC-06.csv%3C%2FP%3E%3CP%3EOutlook%20Folder%20Path%3A%20%5C%5CPersonal_PST%5CUserName1%5CSubfolder2.3%3CBR%20%2F%3EOutlook%20Message%20Count%3A%20143%3CBR%20%2F%3ECSV%20File%20Output%3A%20OutFile_Subfolder2.3_20210125223011_UTC-06.csv%3C%2FP%3E%3CP%3EOutlook%20Folder%20Path%3A%20%5C%5CPersonal_PST%5CUserName1%5CSubfolder2.1%5CDeletions%3CBR%20%2F%3EOutlook%20Message%20Count%3A%2027%3CBR%20%2F%3ECSV%20File%20Output%3A%20OutFile_Deletions_20210125223011_UTC-06.csv%3C%2FP%3E%3CP%3EOutlook%20Folder%20Path%3A%20%5C%5CPersonal_PST%5CUserName1%5CSubfolder2.1%5Csubfolder3.2%3CBR%20%2F%3EOutlook%20Message%20Count%3A%2050%3CBR%20%2F%3ECSV%20File%20Output%3A%20OutFile_subfolder3.2_20210125223011_UTC-06.csv%3C%2FP%3E%3CP%3EPS%20Script%20End!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ESkylar%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2094329%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2101989%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20Export%20all%20Messages%20from%20MS%20Outlook%20into%20CSV%20file%20using%20PowerShell%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2101989%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20guys%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20break%20the%20problem%20in%20to%20small%20piece.%3C%2FP%3E%3CP%3E1.%20Now%20I%20have%20the%20%22Outlook%20Folder%20Path%3A%20%5C%5CPersonal_PST%5CUserName1%5CSubfolder2.1%5Csubfolder3.2%22%20output.%3C%2FP%3E%3CP%3E2.%20I%20want%20to%20use%20this%20method%20%22OutlookNameSpace.Folders.Item(%22Personal_PST%22).Folders.Item(%22UserName1%22).Folders.Item(%22Subfolder2.2%22).Folders.Item(%22Subfolder3.1%22).Items%22%3C%2FP%3E%3CP%3E3.%20So%20I%20need%20to%20process%20the%20Outlook%20folder%20path%20into%20variable%20and%20use%20it%20in%20the%20OutlookNameSpace.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20my%20code%20so%20far%20but%20I%20do%20not%20know%20how%20to%20make%20the%20result%20display%20horizontal.%20I%20am%20open%20for%20any%20advice.%20Thank%20you%20very%20much%20in%20advance.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ECode%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%23PS%20Script%20End%3C%2FP%3E%3CP%3E%23%20Clear%20console%3CBR%20%2F%3EClear-Host%3C%2FP%3E%3CP%3E%23%20Input%20Outlook%20folder%20path%3CBR%20%2F%3E%24OutlookFolderPath%20%3D%20%22%5C%5CPersonal_PST%5CUserName1%5CSubfolder2.1%5Csubfolder3.2%22%3C%2FP%3E%3CP%3E%23%20Split%20Outlook%20folder%20by%20%5C%20and%20store%20ito%20array%20%24SplitOutlookFolderPath%3CBR%20%2F%3E%24SplitOutlookFolderPath%20%3D%20%24OutlookFolderPath.Split(%22%5C%22)%3C%2FP%3E%3CP%3EWrite-Host%20%22Split%20Array%20Output%3A%20%24SplitOutlookFolderPath%22%3C%2FP%3E%3CP%3E%24ArrayCount%20%3D%20%24SplitOutlookFolderPath.Count%3CBR%20%2F%3EWrite-Host%20%22Split%20Array%20count%20%3A%20%24ArrayCount%20%60n%22%3C%2FP%3E%3CP%3E%3CBR%20%2F%3Eforeach(%24FolderName%20in%20%24SplitOutlookFolderPath)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%23%22%24FolderName%20%3D%20%22%20%2B%20%24FolderName.length%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20if(%3CSTRONG%3E%24FolderName.Length%20-ne%200%3C%2FSTRONG%3E)%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%24NewFolderName%20%3D%20%24FolderName%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Write-Host%20%22%24NewFolderName%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%23Write-Host%20%22%60nOutlookNameSpace.Folders.Item(Personal_PST).Folders.Item(UserName1).Folders.Item(Subfolder2.2).Folders.Item(Subfolder3.1).Items%60n%22%3C%2FP%3E%3CP%3E%23PS%20Script%20End%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EPS%20Script%20Output%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3ESplit%20Array%20Output%3A%20Personal_PST%20UserName1%20Subfolder2.1%20subfolder3.2%3CBR%20%2F%3ESplit%20Array%20count%20%3A%206%3C%2FP%3E%3CP%3EPersonal_PST%3CBR%20%2F%3EUserName1%3CBR%20%2F%3ESubfolder2.1%3CBR%20%2F%3Esubfolder3.2%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EI%20want%20the%20output%20to%20display%20like%20below%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3ESplit%20Array%20Output%3A%20Personal_PST%20UserName1%20Subfolder2.1%20subfolder3.2%3CBR%20%2F%3ESplit%20Array%20count%20%3A%206%3C%2FP%3E%3CP%3EOutlookNameSpace.Folders.Item(%3CSTRONG%3EPersonal_PST%3C%2FSTRONG%3E).Folders.Item(%3CSTRONG%3EUserName1%3C%2FSTRONG%3E).Folders.Item(%3CSTRONG%3ESubfolder2.2%3C%2FSTRONG%3E).Folders.Item(%3CSTRONG%3ESubfolder3.1%3C%2FSTRONG%3E).Items%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F941137%22%20target%3D%22_blank%22%3E%40Skylar2000%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi Guys,

 

How are you guys doing today? I am still new to Powershell and keep on learning it every day. I need some helps here, I need to export all MS Outlook messages to CSV files. I know this is easy for some of you guys. Here is my requirements:

 

1. Read all folders in MS Outlook in local system.
2. Display the Outlook folder path that contain the messages.

3. Count number of messages in each folder.
4. If folder got messages, then export the message items with this properties (SenderName, To, SentOn, ReceivedTime, Body) to a CSV file.

 

Here is what I got so far:

1. I managed to connect to the current MS Outlook session using Powershell.

2. I can iterate all the Outlook folders and count number of message items in each folders.

3. Create the CSV output files to hold the messages.

 

However I got zero content for my CSV output. I am having problem to get the Messages item properties from the OutlookNameSpace.

 

I know we can do it like below to get the properties out to CSV files, but how can I use it in my code because the Outlook folders name are dynamic ?

PS C:\WorkDev > $OutlookNameSpace.Folders.Item("Personal_PST").Folders.Item("UserName1").Folders.Item("Subfolder2.2").Folders.Item("Subfolder3.1").Items.count
6

PS C:\WorkDev > $OutlookNameSpace.Folders.Item(2).Folders.Item(2).Folders.Item(2).Folders.Item(1).Items.count
6

PS C:\WorkDev > $OutlookNameSpace.Folders.Item(2).Folders.Item(2).Folders.Item(2).Folders.Item(1).Items | Select-Object -Property SenderName, To, SentOn, ReceivedTime, Body | Export-Csv -Path CSV_OutputFile.csv -NoTypeInformation 

 

Can anybody advice me on how to make this works? Thank you very much in advance. I really appreciate it.

 

Code:

Function Main
{
#Clear console screen
Clear-Host

Write-Host "PS Script Start! `n"

# Import assembly files
Add-Type -assembly "Microsoft.Office.Interop.Outlook"

# This creates a new COM (Component Object Model) Object to access Outlook with.
$Outlook = New-Object -ComObject Outlook.Application

# Map MAPI GetNameSpace to OutlookNameSpace
$OutlookNameSpace = $Outlook.GetNameSpace("MAPI")

# Iterate through all Outlook folders
foreach ($folder in $OutlookNameSpace.Folders)
{
   Get-MailboxFolder $folder
}
Write-Host "`nPS Script End!"
}

Function Get-MailboxFolder($OutlookFolder)
{
#Get current date and time
$GetCurrentDateTime = (Get-Date -format "yyyyMMddHHmmss_UTCzz")

foreach ($f in $OutlookFolder.Folders)
{
    Get-MailboxFolder $f
}

#If $OutlookFolder.Items.Count != 0
if($OutlookFolder.items.count -ne 0)
{
$OutlookFolderPath = $OutlookFolder.FolderPath
$OutlookFolderName = $OutlookFolder.name
$OutlookFolderItemsCount = $OutlookFolder.items.count
$ExportOutlookMessage = $OutlookFolder.Folders.items

# Create the CSV output file
$CSV_OutputFile = "OutFile_"+$OutlookFolderName+"_"+$GetCurrentDateTime+".csv"
$ExportOutlookMessage | Select-Object -Property SenderName, To, SentOn, ReceivedTime, Body | Export-Csv -Path $CSV_OutputFile -NoTypeInformation

Write-Host "Outlook Folder Path: $OutlookFolderPath"
Write-Host "Outlook Message Count: $OutlookFolderItemsCount"
Write-Host "CSV File Output: $CSV_OutputFile `n"
}
}

. Main

 

Here is my script run output:

PS Script Start!

Outlook Folder Path: \\Personal_PST\UserName1\Subfolder2.4
Outlook Message Count: 110
CSV File Output: OutFile_Subfolder2.4_20210125223011_UTC-06.csv

Outlook Folder Path: \\Personal_PST\UserName1\Subfolder2.2\Subfolder3.1
Outlook Message Count: 6
CSV File Output: OutFile_Subfolder3.1_20210125223011_UTC-06.csv

Outlook Folder Path: \\Personal_PST\UserName1\Subfolder2.3
Outlook Message Count: 143
CSV File Output: OutFile_Subfolder2.3_20210125223011_UTC-06.csv

Outlook Folder Path: \\Personal_PST\UserName1\Subfolder2.1\Deletions
Outlook Message Count: 27
CSV File Output: OutFile_Deletions_20210125223011_UTC-06.csv

Outlook Folder Path: \\Personal_PST\UserName1\Subfolder2.1\subfolder3.2
Outlook Message Count: 50
CSV File Output: OutFile_subfolder3.2_20210125223011_UTC-06.csv

PS Script End!

 

Regards,

Skylar :)

1 Reply

Hi guys,

 

I am trying to break the problem in to small piece.

1. Now I have the "Outlook Folder Path: \\Personal_PST\UserName1\Subfolder2.1\subfolder3.2" output.

2. I want to use this method "OutlookNameSpace.Folders.Item("Personal_PST").Folders.Item("UserName1").Folders.Item("Subfolder2.2").Folders.Item("Subfolder3.1").Items"

3. So I need to process the Outlook folder path into variable and use it in the OutlookNameSpace.

 

Here is my code so far but I do not know how to make the result display horizontal. I am open for any advice. Thank you very much in advance.

 

Code:

#PS Script End

# Clear console
Clear-Host

# Input Outlook folder path
$OutlookFolderPath = "\\Personal_PST\UserName1\Subfolder2.1\subfolder3.2"

# Split Outlook folder by \ and store ito array $SplitOutlookFolderPath
$SplitOutlookFolderPath = $OutlookFolderPath.Split("\")

Write-Host "Split Array Output: $SplitOutlookFolderPath"

$ArrayCount = $SplitOutlookFolderPath.Count
Write-Host "Split Array count : $ArrayCount `n"


foreach($FolderName in $SplitOutlookFolderPath)
{
     #"$FolderName = " + $FolderName.length

     if($FolderName.Length -ne 0)
     {
         $NewFolderName = $FolderName
          Write-Host "$NewFolderName"
      }
}

#Write-Host "`nOutlookNameSpace.Folders.Item(Personal_PST).Folders.Item(UserName1).Folders.Item(Subfolder2.2).Folders.Item(Subfolder3.1).Items`n"

#PS Script End

 

PS Script Output:

Split Array Output: Personal_PST UserName1 Subfolder2.1 subfolder3.2
Split Array count : 6

Personal_PST
UserName1
Subfolder2.1
subfolder3.2

 

I want the output to display like below:

Split Array Output: Personal_PST UserName1 Subfolder2.1 subfolder3.2
Split Array count : 6

OutlookNameSpace.Folders.Item(Personal_PST).Folders.Item(UserName1).Folders.Item(Subfolder2.2).Folders.Item(Subfolder3.1).Items

 

 

@Skylar2000