To use PowerShell to export all emails from a specific folder in Outlook, leverage the Outlook COM object model :
# Create an Outlook application object
$outlook = New-Object -ComObject Outlook.Application
# Get the namespace and the default Inbox folder
$namespace = $outlook.GetNamespace("MAPI")
$folder = $namespace.Folders.Item("YourEmail@domain.com").Folders.Item("SpecificFolder")
# Specify the path to export the emails
$outputPath = "C:\ExportedEmails.txt"
# Open a stream to write the emails
$stream = [System.IO.StreamWriter] $outputPath
# Loop through each email in the folder and write to the file
foreach ($mail in $folder.Items) {
$stream.WriteLine("Subject: " + $mail.Subject)
$stream.WriteLine("Body: " + $mail.Body)
$stream.WriteLine("Received: " + $mail.ReceivedTime)
$stream.WriteLine("--------------------------------------------------")
}
# Close the stream
$stream.Close()?