Outlook body is blank

Add-Type -Path "C:\Program Files (x86)\Microsoft\Exchange\Web Services\2.1\Microsoft.Exchange.WebServices.dll"

$EmailAccount = "test@test.com"

#Change the Exchange Version to work with your environment
$EWS = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1)

#Change the “UseDefaultCredentials” to false if you want to specify alternate creds
#$EWS.UseDefaultCredentials = $false

$EWS.AutodiscoverUrl($EmailAccount)

$inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($ews,[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox)

$mailitems = $inbox.FindItems(10)  


$SEPmail = $mailitems | ? {$_.conversationtopic -like "*Security Alert by Number of Attacked Computers*"}

This will pull up the correct emails, but any email it grabs, the body property is blank…

If i just do the line below it brings up the sender, subject just fine, but the body is blank. I’m not sure why…if anyone has any suggestions i would greatly appreciate it.

$inbox.FindItems(10) | select sender, subject, body

I believe you have to load each item.

$emails = $inbox.FindItems(10)
$emails.load()

If that doesn’t work, explore the methods by piping into gm… I don’t have access to do it right now.

doing a | gm I do see the body property…doing a $mailitems.load I get


OverloadDefinitions

void Load(Microsoft.Exchange.WebServices.Data.PropertySet propertySet)
void Load()

void Load(Microsoft.Exchange.WebServices.Data.PropertySet propertySet)
void Load()

void Load(Microsoft.Exchange.WebServices.Data.PropertySet propertySet)
void Load()

void Load(Microsoft.Exchange.WebServices.Data.PropertySet propertySet)
void Load()

void Load(Microsoft.Exchange.WebServices.Data.PropertySet propertySet)
void Load()

void Load(Microsoft.Exchange.WebServices.Data.PropertySet propertySet)
void Load()

void Load(Microsoft.Exchange.WebServices.Data.PropertySet propertySet)
void Load()

void Load(Microsoft.Exchange.WebServices.Data.PropertySet propertySet)
void Load()

void Load(Microsoft.Exchange.WebServices.Data.PropertySet propertySet)
void Load()

void Load(Microsoft.Exchange.WebServices.Data.PropertySet propertySet)
void Load()

You nailed it…I was missing the .load()

Thanks!!!