1

I'm trying to use powershell to search through all items my outlook 2013 inbox. But I've noticed that items returned have a blank body property, example:

$outlook = New-Object -Com Outlook.Application
$mapi = $outlook.GetNamespace('MAPI')
$mailboxRoot = $mapi.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox).Parent

$mailboxRoot.Folders[2].Items[1].Body
$mailboxRoot.Folders[2].Items[1].RTFBody
$mailboxRoot.Folders[2].Items[1].HTMLBody

and the item I was looking at, in the second folder, first item, is a legitimate e-mail and has text in outlook if I pull it up.

I don't have issues with the subject or other fields, just the body.

So how do I get the contents of the body for e-mail items?

  • Have you considered using the dlls directly instead of COM interop? https://stackoverflow.com/questions/4454165/how-to-check-an-exchange-mailbox-via-powershell – Eris Nov 27 '17 at 21:02
  • Pretty sure that should be `$mailboxRoot.Folders[2].Items(1).Body` or `$($mailboxRoot.Folders[2].Items)[1].Body`. Been a half a year or so since I used the Outlook ComObject, but I don't think it'll iterate the items like you have it there. – TheMadTechnician Nov 28 '17 at 00:07

0 Answers0