Hi @Andrei B,
Azure Communication Services' Email feature does support webhooks for events such as delivery, bounce, opened, etc. These are identified using the messageId
which is Generated by Azure itself when you send an email. Only accessible when sending emails via the ACS SDK or REST API, because those return the messageId
in the response.
Unfortunately, when you send emails via SmtpClient
, ACS doesn't expose the generated messageId
back to you. Additionally, Custom headers like X-Message-Id
are not recognized by ACS for tracking purposes. There’s currently no supported way to explicitly set or retrieve the messageId
when using SmtpClient
.
If you need to reliably track bounces or other email events via webhooks, you will need to switch to the ACS Email SDK or REST API, at least for sending. Here's why:
- Only the SDK/API provides the generated
messageId
in the response. - That
messageId
is referenced in all delivery and bounce events, allowing you to correlate sent messages with webhook payloads.
- Use ACS Email SDK: This is the most straightforward way:
- After sending the email, you receive the
MessageId
immediately. - You can store it and correlate it with incoming webhook events. Send Email using Azure Communication Services
- After sending the email, you receive the
- If you want to avoid SDKs, you can call the REST API directly. You’ll still receive the
messageId
in the JSON response. https://learn.microsoft.com/en-us/rest/api/communication/email/email/send?view=rest-communication-email-2023-03-31&tabs=HTTP
If you're strictly limited to using SmtpClient
(and not ACS SDK or API), you won’t be able to capture the messageId
and therefore cannot reliably correlate events from webhooks. This is a current limitation of ACS when used via SMTP.
https://learn.microsoft.com/en-us/answers/questions/1464206/question-about-the-message-id-when-sending-service
https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/email/send-email-smtp/send-email-smtp?tabs=dotnet&pivots=smtp-method-smtpclient
If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.
Let me know if you have any further Queries.