Options to search content in .msg files saved in SharePoint Online - PowerShell options

Nishanth Chakkere 165 Reputation points
2024-07-30T23:02:06.1533333+00:00

Hi,

I had asked the question below in another Microsoft forumand was advised to ask the question in the SharePoint Development forum, as the query is related to PowerShell.

I am working on the options available to search the content in .msg files saved in SharePoint Online. I did some testing and noticed that the out-of-the-box search capabilities available in SPO do not bring up the appropriate search results for .msg files saved in SPO.

My specific use cases are as follows:

  • Searching email files by their subject.

Searching email files by the recipient (sent to and cc recipients).

Searching email files by the sender details (name and email address).

Searching email files by specific date or within a date range.

Searching email files that have attachments in them (i.e., the email had files attached to it).

Questions:

  • Are there PowerShell scripts available to optimise / customise the search of .msg files stored in SharePoint?
  • Are there options available in SPO to obtain better search results for the above scenarios?

Is this a good use case for KQL to be used?

Does creating more site level filters and verticals in MS Search improve the quality of search?

Thank you.

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,028 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,576 questions
{count} votes

Accepted answer
  1. Yanli Jiang - MSFT 26,681 Reputation points Microsoft Vendor
    2024-08-02T07:48:02.2866667+00:00

    Hi @Nishanth Chakkere ,

    Welcome to Q&A forum!

    I'm sorry to get back to you so late, I've been unwell due to the novel coronavirus so I've taken some time off.

    There are PowerShell scripts available to optimize/customize the search of .msg files stored in SharePoint, but it is recommended to use the Content Search tool in Microsoft 365 compliance center to search for content in SharePoint Online. The Content Search tool allows you to search for specific content in SharePoint Online, including .msg files, and provides more advanced search options than the out-of-the-box search capabilities in SharePoint Online. You can search for .msg files by subject, recipient (sent to and cc recipients), sender details (name and email address), specific date or within a date range, and files that have attachments in them. It is also possible to use KQL to search for content in SharePoint Online, but it may not be necessary if the Content Search tool provides the necessary search options. Creating more site level filters and verticals in MS Search may improve the quality of search, but it is not directly related to searching for .msg files in SharePoint Online.

    For your references:

    Finding content in SharePoint and OneDrive

    Feature reference for Content search


    If the answer is helpful, please click "Accept as Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 46,806 Reputation points
    2024-08-04T02:17:36.08+00:00

    The .msg file isn't a plain text file.

    You can use the Outlook COM object to read that type of file, but using Outlook on a server is usually frowned on.

    Saving the message as .eml files (which are a lot easier to deal with) would be easier. The .eml can either be entirely plain text with attachments included as Base64. Or they can be MIME messages. MIME is more complicated, but you can use the MimeKit module to get at the pieces of the message that are interesting to you.

    There's also a PowerShell module, ReadMsgFile that you can use to read the .msg file.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.