Powershell script to extract outlook attachments

Hello, I really need your help!

I have a script that reads my entire outlook mailbox and can retrieve the contents. Now I can’t get the attachments in the mails to retrieve the content of the mails.
Can you please help me to succeed in this part? I have attached the script to access my outlook box

Thanks in advance

Diouf,
Welcome to the forum. :wave:t4:

No, you have not. :wink:

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

Hello, thank you for the information :grinning:
Now, i can attach the script.

Function Get-OutlookInBox

{

 Add-type -assembly “Microsoft.Office.Interop.Outlook” | out-null

 $olFolders = “Microsoft.Office.Interop.Outlook.olDefaultFolders” -as [type]

 $outlook = new-object -comobject outlook.application

 $namespace = $outlook.GetNameSpace(“MAPI”)

 $folder = $namespace.getDefaultFolder($olFolders::olFolderInBox)

 $folder.items | Select-Object -Property Subject, ReceivedTime, Importance, SenderName, Body 


} #end function Get-OutlookInbox


# Create the txt output file
$date = Get-Date -Format "yyyyMMdd"
$CSV_OutputFile = "Out_res_"+$folder+$date+".txt"


$Inbox = Get-OutlookInBox
$test=$InBox | where { $_.Subject -match ‘Scheduled Task Scripting’ } | sort ReceivedTime -Descending

Your code is broken. There are some weird characters.

Sorry, i repaired it