I have a basic folder in my outlook with alerts from a monitoring system. I would like to create a table based upon that data. To that end I have been trying to access the body content of emails in Outlook:
Add-Type -Assembly "Microsoft.Office.Interop.Outlook"
$Outlook = New-Object -ComObject Outlook.Application
$namespace = $Outlook.GetNameSpace("MAPI")
$inbox = $namespace.GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox)
$inbox.Items | Format-Table BodyFormat, Body, HTMLBody, RTFBody
Now I would expect to see some content for Body, HTMLBody, or RTFBody -- I do not. I DO see that BodyFormat is most often 2 (olFormatHTML). So most of the emails should have content in HTMLBody -- None of them do. I can access the subject lines but not the content.
Since every example I find online seems to be able to get the body content I think it must be a setting in outlook to only download the subject lines or something. We have Enterprise Vault -- could the content be stored separate from the message?
Based upon the MSDN documentation I believe that this is indeed the Anti-virus blocking access to selective properties via the Object Model Guard. This explains why the $mm.Body
property is settable but not gettable. Since I do not have access to any of the corporate security settings on my machine I was unable to pursue the interop direction any further.
There are a few workaround suggestions
I think I will be working with the EWS although I have to say that the interface is rather complicated.
thanks to @TessellatingHeckler for point me on the path.