How to read Message body from Exchange server massage store using power shell query RRS feed

  • Question

  • Hi

    I want to read all mailbox user send message body using power shell query ,if anybody know about that pls help me ....



    Wednesday, June 24, 2015 5:07 AM


All replies

  • Hello Manidurai,

    It is not clear when and where you need to run a PowerShell script... Anyway, you can automate Outlook to get the job done. See Managing an Outlook Mailbox with PowerShell .

    The Outlook object model provides three main ways for working item bodies:

     1. Body -  a string representing the clear-text body of the Outlook item. 
     2. HTMLBody - a string representing the HTML body of the specified item.
     3. The Word editor - the Microsoft Word Document Object Model of the message being displayed. The WordEditor property of the Inspector class returns an instance of the Document class from the Word object model which you can use to set up the message body.

    You can read more about all these ways in the Chapter 17: Working with Item Bodies. It us up to you which way is to choose to read the message body.

    The ItemSend event is fired henever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Sendbutton) or when the Send method for an Outlook item, such as MailItem, is used in a program.

    Wednesday, June 24, 2015 6:53 AM
  • Hi Eugene 

      i want to get reports based on all users mail message body. then do u have any direct  powershell query to read message body of all users mail and also i need powershell query to get  unread messages count for all users ..

    Wednesday, June 24, 2015 1:39 PM
  • Hi Manidurai,

    For your requirement, Engene’s reply is complete, you could base on his reply to accomplish that.



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 26, 2015 8:35 AM
  • No, I don't use PowerShell scripts.

    You can use the Restrict or Find/FindNext methods of the Items class to get the number of unread emails easily. The Count property of the Items class returns an integer indicating the count of objects in the specified collection. You may find the following articles helpful:

    How To: Use Restrict method to retrieve Outlook mail items from a folder

    How To: Use Find and FindNext methods to retrieve Outlook mail items from a folder (C#, VB.NET)

    Also take a look at the AdvancedSearch method of the Application class which performs a search based on a specified DAV Searching and Locating (DASL) search string.

    The key benefits of using the AdvancedSearch method in Outlook are:

    • The search is performed in another thread. You don’t need to run another thread manually since the AdvancedSearch method runs it automatically in the background.
    • Possibility to search for any item types: mail, appointment, calendar, notes etc. in any location, i.e. beyond the scope of a certain folder. The Restrict and Find/FindNext methods can be applied to a particular Items collection (see the Items property of the Folder class in Outlook).
    • Full support for DASL queries (custom properties can be used for searching too). You can read more about this in the Filtering article in MSDN. To improve the search performance, Instant Search keywords can be used if Instant Search is enabled for the store (see the IsInstantSearchEnabled property of the Store class).
    • Finally, you can stop the search process at any moment using the Stop method of the Search class.

    Read more about the method in the Advanced search in Outlook programmatically: C#, VB.NET article.

    Friday, June 26, 2015 11:54 AM
  • FWIW, powershell/exchange scripting resources are available at;[0].Type=RootCategory&f[0].Value=Exchange

    Friday, June 26, 2015 12:14 PM