When I use Microsoft Graph to retrieve a message's toRecipients
or internetMessageHeaders
, I am unable to find the actual email alias that the mail was sent to. How do I get the alias? It is always returning the "parent" account, never the alias account.
For example, this shows alias1@company.com
as an alias to account email1@company.com
.
Request:
https://graph.microsoft.com/v1.0/users/email1@company.com?$select=proxyAddresses
Response:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(proxyAddresses)/$entity",
"proxyAddresses": [
"smtp:alias1@company.com",
"X500:/o=Org1/ou=External (xxxxx)/cn=Recipients/cn=00000000000000000000",
"x500:/o=ExchangeLabs/ou=Exchange Administrative Group (xxxxx)/cn=Recipients/cn=1111111111111111",
"smtp:email1@company.mail.onmicrosoft.com",
"X500:/o=Org1/ou=Exchange Administrative Group (xxxxx)/cn=Recipients/cn=yyyyyyyy",
"smtp:email1@company.onmicrosoft.com",
"SMTP:email1@company.com"
]
}
I then send an email to alias1@company.com
. I do not see the alias when retrieving toRecipients
or internetMessageHeaders
, only the parent account email@company.com
.
Request:
https://graph.microsoft.com/v1.0/me/messages/{messageId}?$select=toRecipients,internetMessageHeader
Response:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('...')/messages(toRecipients,internetMessageHeaders)/$entity",
"@odata.etag": "W/\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"",
"id": "{messageId}",
"internetMessageHeaders": [
{
"name": "Received",
"value": "...."
},
{
"name": "Received",
"value": "..."
},
{
"name": "Received",
"value": "..."
},
{
"name": "Authentication-Results",
"value": "company.com; dkim=none (message not signed) header.d=none;company.com; dmarc=none action=none header.from=company.com;"
},
{
...
}
],
"toRecipients": [
{
"emailAddress": {
"name": "FirstName LastName",
"address": "email1@company.com"
}
}
]
}