Sending mail with Microsoft Office 365 & "ApplicationIdAndSecret"

Hello everyone,

I’m trying to use “Microsoft Office 365 Scope” with ‘ApplicationIdAndSecret’ as authentification to send an email, but it doesn’t work.

The properties for Application ID, Tenant and Application Secret & Secure Application Secret are correctly set.

image

Package used:

image

Error message:

image

If you have any insight please share it.

Thanks for your help :slight_smile:

Hi @Geoffroy_Pantegnies

Check the below thread

Regards

@Geoffroy_Pantegnies

  1. Did you fill the account field in send email it is mandatory
  2. If 1 is ok then send the complete exception message from locals panel

Cheers

Thanks Parvathy,

Checked them but nothing I haven’t done.

Thanks for answering Anil.

It was not field but marked as optional. Even when field the error remains.

Here is the complete message :

Microsoft.Graph.ServiceException: Code: generalException
Message: An error occurred sending the request.
—> Microsoft.Identity.Client.MsalServiceException: AADSTS1002012: The provided value for scope mail.read mail.readwrite mail.send is not valid. Client credential flows must have a scope value with /.default suffixed to the resource identifier (application ID URI). Trace ID: 2a332757-c89b-4f57-9bfb-78593facb900 Correlation ID: 7555905c-12c3-46d8-a5a5-107d91c835a3 Timestamp: 2024-02-29 08:18:30Z at Microsoft.Identity.Client.Internal.Requests.RequestBase.HandleTokenRefreshErrorAsync(MsalServiceException e, MsalAccessTokenCacheItem cachedAccessTokenItem)
at Microsoft.Identity.Client.Internal.Requests.ClientCredentialRequest.ExecuteAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.ApiConfig.Executors.ConfidentialClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenForClientParameters clientParameters, CancellationToken cancellationToken)
at UiPath.Shared.Authentication.Microsoft.Services.MsalLogonService.AuthenticateInternalAsync(OAuthDataOptions oauth, CancellationToken cancellationToken)
at UiPath.Shared.Authentication.Microsoft.Services.MsalLogonService.AuthenticateAsync(OAuthDataOptions oauth, CancellationToken cancellationToken)
at UiPath.Shared.Services.Graph.GraphClientServiceFactory.TimeoutAfter[TResult](Task1 task, String authenticationType, Int32 timeoutMs) at UiPath.Shared.Services.Graph.GraphClientServiceFactory.LoginFromCacheOrExplicitAsync(OAuthDataOptions model, CancellationToken ct) at UiPath.Shared.Services.Graph.GraphClientServiceFactory.ResolveAccessTokenAsync(Task1 authResolver)
at UiPath.Shared.Services.Graph.GraphClientServiceFactory.AuthenticateAsync(OAuthDataOptions model, CancellationToken cancellationToken)
at UiPath.Shared.Authentication.Microsoft.Extensions.HttpRequestMessageExtensions.AuthorizeAsync(HttpRequestMessage request, Func2 getToken, CancellationToken ct) at Microsoft.Graph.AuthenticationHandler.SendAsync(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Microsoft.Graph.SimpleHttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) --- End of inner exception stack trace --- at Microsoft.Graph.SimpleHttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) at Microsoft.Graph.SimpleHttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption) at Microsoft.Graph.BaseRequest.SendAsync[T](Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption) at UiPath.Shared.Services.Graph.Mail.Extensions.GraphServiceClientExtensions.SaveMailMessageAsDraftAsync(GraphServiceClient graphClient, Message message, String address, CancellationToken cancellationToken) at UiPath.MicrosoftOffice365.Extensions.FromShared.GraphServiceClientExtensions.CreateDraftMailMessageAsync(GraphServiceClient graphClient, String address, String[] toRecipients, String subject, String body, IResource[] attachments, String[] ccRecipients, String[] bccRecipients, String[] replyToRecipients, String fromRecipient, Boolean isBodyHtml, Importance importance, IEnumerable1 contentIdMap, CancellationToken cancellationToken)
at UiPath.MicrosoftOffice365.Services.GraphServiceClientProxy.SendMailAsync(SendMailRequest request, CancellationToken cancellationToken)
at UiPath.MicrosoftOffice365.Activities.Mail.SendMail.ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
at UiPath.Shared.Activities.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at UiPath.Shared.Activities.ContinuableAsyncCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at UiPath.MicrosoftOffice365.Activities.Office365BaseClientActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at UiPath.MicrosoftOffice365.Activities.Office365ClientActivity`2.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Cheers

@Geoffroy_Pantegnies

for application sercret and certifcate that field is mandatory

and also asper error looks like the user level permissions are missing

cheers

In newer version we recommend:

  • using the Asset approach
  • or set the values directly
    So in the design time the app scope can be invoked (with Variables it will not do, we get the yellow box message)

Also have a look here:

@ppr @Anil_G @Parvathy

Thanks all for your answers.

The solution is linked to my Studio’s version, for the Microsoft package, a minimum is required:

image

Have a nice day

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.