powershell outlook showing content from other e-mail -
i have powershell script prints senderemailaddress, , subject. problem when asking content get-content $txtcontent | select -index 23 content e-mail. maybe there method clear cache or because content previous e-mail , don't know how fix this. $txtcontent= "c:\test.txt"; $matchstring= "info@blabla.com"; $olfolderinbox = 6 $outlook = new-object -com outlook.application; $mapi = $outlook.getnamespace("mapi"); $inbox = $mapi.getdefaultfolder($olfolderinbox) $inbox.items | select -last 1 senderemailaddress,to,subject $inbox.items | { $_.senderemailaddress -match $matchstring } | out-file $txtcontent get-content $txtcontent | select -index 23 when using get-content $txtcontent content of e-mail need. when need line 23 content another, previous e-mail