0

i am trying to get the body of an email and set it to a variable with powershell by using get-mailbox. the reason im not doing it an easier was is it is blocked on the network to get the body from outlook. im completly lost. ive tried export but thats to pst. ive tried doing a search query with logging but thats a bust also. im pretty lost anything to point me in the direction would be great.

TLDAN
  • 53
  • 2
  • 12
  • Are you trying to do this with your own mailbox? / Do you have outlook installed from where your running the script – Cole9350 Apr 24 '14 at 19:10

2 Answers2

2

As far as I know, Get-Mailbox won't do that, unfortunately. It'll get you information about the mailbox, but not it's contents. If you want to work w/ the contents of a mailbox, and you can't use Outlook, your best bet is probably the Exchange Web Service (EWS).

Hunter Eidson
  • 1,896
  • 14
  • 23
0

There is a way to do this but it really depends on how much you are willing to work to make it possible.

The best way that I could think of is using the EWS API. It's messy and it takes a while to learn so you will probably need to put some time and effort into making the script (unless you can find someone else who has).

Basically I got all of these links by doing a google search for "Powershell EWS API"

Here is another similar question: How to check an exchange mailbox via powershell?

Here is some more help with how to use the API (it's kinda tricky): http://blogs.technet.com/b/heyscriptingguy/archive/2011/12/02/learn-to-use-the-exchange-web-services-with-powershell.aspx http://www.xipher.dk/WordPress/?p=739

Here are some examples to work off of (the first one is closest to what you are looking for): http://social.technet.microsoft.com/Forums/scriptcenter/en-US/335a888b-bf85-4a36-a555-71cc84608960/download-email-content-text-from-exchange-ews-with-powershell?forum=ITCG http://social.technet.microsoft.com/Forums/exchange/en-US/0ad086bd-eb23-4ece-a362-696fa526a7e6/retrieve-messages-from-inbox-subfolder?forum=exchangesvrdevelopment http://poshcode.org/2978

Hope that helps!

Community
  • 1
  • 1
Schuyler
  • 509
  • 1
  • 9
  • 19