Hi there,
I’ve got an AL routine that sends email just fine if a user clicks an action. However I need to have my service app running as an Azure AD Application call this email function. It gets the following stack trace.
“Email - OAuth Client”(CodeUnit 4507).TryGetAccessTokenInternal - Email - Outlook REST API by Microsoft
“Email - OAuth Client”(CodeUnit 4507).GetAccessToken - Email - Outlook REST API by Microsoft
“Email - Outlook API Helper”(CodeUnit 4509).Send line 13 - Email - Outlook REST API by Microsoft
“Microsoft 365 Connector”(CodeUnit 4503).Send line 4 - Email - Microsoft 365 Connector by Microsoft
“Send Email”(CodeUnit 8890).OnRun(Trigger) line 5 - System Application by Microsoft
“Email Dispatcher”(CodeUnit 8888).OnRun(Trigger) line 30 - System Application by Microsoft
“Email Impl”(CodeUnit 8900).Send line 41 - System Application by Microsoft
“Email Impl”(CodeUnit 8900).Send line 4 - System Application by Microsoft
“Email Impl”(CodeUnit 8900).Send line 7 - System Application by Microsoft
Email(CodeUnit 8901).Send line 2 - System Application by Microsoft
“Email Notifications”(CodeUnit 60505).AlertNotify line 16 - Denbridge Data Service by Port of Aberdeen
The code it’s calling is a very simple
EmailMsg.Create(TxtRecipientList, header, message, false);
Email.Send(EmailMsg, Enum::“Email Scenario”::“Denbridge Sync Scenario”);
The scenario exists and as I saw all works perfectly when initiated by a user action largely I suspect because the email is then sent by the user.
I suspect the issue is probably permissions and somewhere I need to set something to allow the Azure AD App to send as the email scenario user. I think this could be in the API permissions of the Azure AD App but I’ve tried adding the obvious ones in Microsoft Graph ie: all of the Mail. ones particularly Mail.Read and Mail.Send permission has been granted on behalf of organisation.
Anyone know how to get al code to send an email when the code is running from an Azure AD app and not via user actions?