Understanding dead letters in email tracking
Who is this article for?
Administrators who want to understand what a dead letter is in respect to email tracking.
Administrator permissions are required.
A dead letter is a message that has failed delivery multiple times and has been moved to a special queue for investigation and resolution.
Understanding what a dead letter is
Email tracking runs on the customer's own Azure Service Bus. When a user saves an email, The email tracking service puts a message on the emailtrackingtransactions queue. It then splits that into one message per internal recipient on emailtrackingrequests. Each of those calls Microsoft Graph to stamp that recipient's copy of the email with the SharePoint location and the Transferred to SharePoint category.
If a message fails 10 delivery attempts, Service Bus moves it into that queue's dead-letter sub-queue (<queue>/$deadletterqueue). In practice, this means one or more recipients never received their tracking stamp. The email tracking service has its own triggers that listen on those dead-letter queues.
Troubleshooting dead letters
Finding the dead letters
To locate dead letters:
- In the customer's Azure portal, open the Service Bus namespace.
- Select Queues.
- Check the dead-letter count on
emailtrackingtransactionsandemailtrackingrequests. - Open Service Bus Explorer on the dead-letter sub-queue.
- Peek at the messages.
The DeadLetterReason and DeadLetterErrorDescription properties usually name the cause, such as MaxDeliveryCountExceeded.
Checking health
To check the health status:
- Call
GET /api/healthwith thex-health-check-keyheader.
The response codes indicate:
- 200 means healthy
- 401 means a bad key
- 503 means Service Bus or Cosmos DB is down
Checking Application Insights
To investigate exceptions:
- Check Application Insights for exceptions around the time the messages were dead-lettered.
The common causes are:
- Graph 401/403: the app registration's client secret has expired (it needs renewing every two years), or admin consent for
Mail.ReadWriteor the user and group read permissions is missing - Graph 404: the recipient's mailbox or the message no longer exists
- Graph 429: throttling during a burst, for example a large distribution list
- licence-token failures: the licence is invalid or has lapsed
- Cosmos DB firewall blocking the Function App after scaling
Fixing and replaying
To resolve dead letter issues:
- Fix the root cause first by renewing the secret, re-granting consent, fixing the licence, or opening the firewall.
- Resubmit the dead-lettered messages to the main queue using Service Bus Explorer's resubmit option or a script.
- Purge any that are permanently invalid, such as messages for deleted mailboxes.
Important: If you replay before fixing the cause, the messages will just dead-letter again after another 10 tries.