Outlook body is blank

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of ertuu85 ertuu85 2 months, 1 week ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #46579
    Profile photo of ertuu85
    ertuu85
    Participant
    Add-Type -Path "C:\Program Files (x86)\Microsoft\Exchange\Web Services\2.1\Microsoft.Exchange.WebServices.dll"
    
    $EmailAccount = "[email protected]"
    
    #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
    
    #46591
    Profile photo of Dan Potter
    Dan Potter
    Participant

    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.

    • This reply was modified 2 months, 2 weeks ago by Profile photo of Dan Potter Dan Potter.
    #46753
    Profile photo of ertuu85
    ertuu85
    Participant

    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()
    
    #46755
    Profile photo of ertuu85
    ertuu85
    Participant

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

    Thanks!!!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.