Quantcast
Channel: Glen's Exchange and Office 365 Dev Blog
Viewing all articles
Browse latest Browse all 241

Getting Teams Chat History Messages (Compliance Records) From a Mailbox using EWS and/or in Outlook Add-in

$
0
0

 Microsoft made a recent change to where the compliance messages get stored in a Mailbox for private Teams Chats from the \Conversation History\Teams Chat Folder to a non_ipm_subtree folder called TeamsMessagesData (see https://office365itpros.com/2020/10/14/microsoft-changes-location-teams-compliance-records/ for some good commentary on this change). In terms of programmatic access to these messages this change affects the ability of the Graph (and Outlook REST) Endpoints to access them. While you could never access the Folder directly with the Graph API (because of the FolderClass) the messages themselves would appear in the \Messages endpoint (this is because they where captured by the underlying AllItems Search folder that backs this endpoint). Now the messages are in the Non_IPM_Subtree you loose the ability of that Search Folder to access those messages. This first up broke my OWA add-in from https://gsexdev.blogspot.com/2019/03/microsoft-teams-private-chat-history.html that could be used to show the Chat History for a user using the compliance messages in a Mailbox  eg



While the Graph and Outlook REST Endpoints can't be used to access these compliance records anymore (unless you create your own search folder to expose them). You can use EWS to still access them, to fix my Outlook Add-in this meant switching the code from using the Outlook Rest Endpoint to EWS to accessing these message. I also wrote a script to show how these message could be accessed via powershell

There are two ways of getting the TeamsMessagesData Folder in EWS the first is you can use an Extended property that exists on the Inbox folder that will contain the hex entryId to the TeamsMessagesData Folder you then need to convert that to an EWS id and then bind to the Folder eg (In the script I've done this)


The other way is just find the folder using its name in the Root of the Non_IPM_Subtree. (In the Plugin I do this)


With the script it means is I can do something like this to view the Chat messages in a Mailbox (last 30 days) eg


As well as changing the Add-in from using the Outlook Rest endpoint to EWS I've also included a look back dropdown so if you want to see more then the default 60 days of messages you now can eg


(what you will see will depend on the Retention policy for your compliance records ).

The script is available from https://github.com/gscales/Powershell-Scripts/blob/master/GetTeamsChatMessages.ps1

With the Add-in is I've hosted the files on my GitHub pages so its easy to test (if you like it clone it and host it somewhere else). But all you need to do is add it as a custom addin (if your allowed to) using theURL

  https://gscales.github.io/TeamsChatHistory/TeamsChatHistory.xml



The GitHub repository for the Addin can be found here https://github.com/gscales/TeamsChatHistoryOWAAddIn




Viewing all articles
Browse latest Browse all 241

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>