Retrieving the headers of an e-mail message
When troubleshooting mail flow issues, you may need to take a look at the headers of an e-mail message. This is easy to do through Outlook for items in your own mailbox, but if you want to do this on behalf of another user, it requires you to have permissions to their mailbox, and then you need to open their mailbox in Outlook to view the headers. In this recipe, we'll take a look at how you can retrieve the headers of a message in your own mailbox, as well as another user's mailbox, using the EWS Managed API and PowerShell.
How to do it...
First, load the assembly, create the
ExchangeService
object, and connect to EWS:Add-Type -Path C:\EWS\Microsoft.Exchange.WebServices.dll $svc = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService $svc.AutoDiscoverUrl("administrator@contoso.com")
Next, create a view for the total number of items that should be returned from the search:
$view = New-Object -TypeName ` Microsoft.Exchange.WebServices.Data...