How Teams Channels Receive Email

Connectors Link Teams to Email

The Email addresses for Teams channels are interesting objects. Channels start off without email addresses and only get one when a team member retrieves an address for the first time (Figure 1). That email address stays in place until it is removed. Once the Teams channel email address exists, it can be used like any other email address, including being used for an Exchange Online mail contact object that appears in the GAL, or as a member of a distribution list.

Rather oddly in the opinion of some, any team member (from the tenant – not guests) can remove the email address from a channel. It seems like it would be better if this was something that only a team owner could do.

Getting the email address for a Teams channel
Figure 1: Getting a Teams channel email address

Phantom Mailboxes and Connectors

Behind the scenes, when an email address is assigned to a channel, Office 365 creates a “phantom” Exchange Online mailbox in a special tenant to receive email for the channel. The mailbox is a phantom because it can’t be seen by any public interface. When new messages arrive in the mailbox, Teams uses a connector to fetch and post the messages as new topics in the channel.

If the message is small enough (under 2,000 characters as a rough estimate), Teams can display the full text in the channel. Otherwise the user needs to access the copy of the message (plus any attachments) which Teams captures in an “email messages” folder (named for the month) in the Channel folder of the SharePoint document library belonging to the team.

Replies posted to email messages in channels remain in Teams and are not copied back to the original message recipients.

Finding Audit Records When Teams Channels are Email-Enabled

All of which brings us to how to know when a Teams channel is mail-enabled. One way is to use the PowerShell script described in this article to report teams channels that are mail-enabled (the script uses a mixture of PowerShell and Graph calls because the email address for channels is not revealed by the Get-TeamChannel cmdlet). Another method is to look for the events in the Office 365 audit log that Teams creates when a connector is added to enable email access to a channel or removed from a channel. Here’s a quick and dirty script to find the audit records and extract the necessary data from the audit payloads:

# Find Office 365 audit records when an Email Connector is added or removed
# from a Teams channel
CLS; Write-Host "Searching Office 365 Audit Records to find Email Connectors added to Teams channels"
$StartDate = (Get-Date).AddDays(-90); $EndDate = (Get-Date) #Maximum search range for audit log for E3 users
[array]$Records = (Search-UnifiedAuditLog -Operations ConnectorAdded, ConnectorRemoved -StartDate $StartDate -EndDate $EndDate -ResultSize 1000)
If ($Records.Count -eq 0) {
    Write-Host "No audit records for connectors found." }
Else {
    Write-Host "Processing" $Records.Count "audit records..."
    $Report = [System.Collections.Generic.List[Object]]::new() # Create output file for report
    # Scan each audit record to extract information
    ForEach ($Rec in $Records) {
      $AuditData = ConvertFrom-Json $Rec.Auditdata
      If ($AuditData.AddOnName -eq "Email Connector") {
          $ReportLine = [PSCustomObject]@{
           TimeStamp = Get-Date($AuditData.CreationTime) -format g
           User      = $AuditData.UserId
           Action    = $AuditData.Operation
           Team      = $AuditData.TeamName
           Connector = $AuditData.AddOnName
           Channel   = $AuditData.ChannelName }
      $Report.Add($ReportLine) }

$Report | Format-Table TimeStamp, Action, Team, Channel, User -AutoSize

Figure 2 shows what you might see as a result of running the script. You can export the information to a CSV file if you need to preserve it for further examination.

Teams Channels Get or Lose Email Connectors
Figure 2: Teams Channel email address audit records generate this kind of information

Finding Email-Enabled Channels

Audit records can only tell us when Teams channel email addresses exist over a limited period (90 days for E3 tenants, 365 days for E5 tenants). A mixture of tracking audit changes and reporting on channels periodically should be enough to keep an eye on what’s happening for this aspect of a tenant.

The Office 365 for IT Pros eBook includes hundreds of PowerShell examples to help you manage different aspects of your tenant. Shouldn’t you be a subscriber and receive monthly updates?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.