Office 365 - Send Mail

Hi all,

I’m trying to use Office365 dependency to send emails, but i’m not able i don’t know why. I have no control over Azure configurations, but the team in charge of that actions has followed next steps:

https://docs.uipath.com/activities/docs/office365-setup

  1. We have created an application in Azure
  2. We have granted rights over mails, users, files, offline_access, etc.
  3. We have generated a secret value, to use while connecting to Office365.
  4. The robotic user is owner of the application

While executing a very simple sequence (only Office365 scope and send mail) i’m getting this error:
image

If i execute the same sequence, without send file activitiy, it works, so it has to be something related to rights over the application or any other setup that is missing. Has anyone faced this error? Is it needed any other extra steps not described in the uipath guide?

Any idea is welcomed. Let me know if you need to know any other specific information, but keep in mind that because of NDA i won’t be able to share too much information.

Regards and thanks in advance

Hi @Alvaro_RS

Can you run any sharepoint related activities and check if you are able to access?

A simple get list info should do the job to check

So that we know if its credentials or only with email

Cheers

Hi,

I’ve tried some other activities and the result is exactly the same ‘Access denied’ message.

Regards

Hi @Alvaro_RS

Can you tell which authetication type you are using? And also if mfa is enabled on your accounts?

And I hope you picked up the right set of application secret if you are using that

Please check support matrix here depending on user

Cheers

Hi,

I’m using ApplicationIdAndSecret and MFA is disabled.

I have some doubts about the matrix you are sending me. It is supposed that i cannot run my flow until i deployed it and test it in unattended mode? To run a workflow with Studio, i have to use ‘InteractiveToken’ authentication?

Regards

Hi @Alvaro_RS

No …You need not use interactive token for working in studio. You can go with APPID and secret as well.

Can you confirm if these values are provided and you have selected Services from the properties

Can you show

Hi,

This is the current setup i’m executing:


Regards

Hi @Alvaro_RS

Can you select interactive token as UIPath please and I hope the email you provided in from is having domain name to it(Eg: username@uipath.com)

And I hope you got the right values from azure

cheers

Hi,

I’ve tested it again and the result is exactly the same.

As i said, just the activity ‘Microsoft Office365 Scope’ works if it is executed separetely, so Azure values must be correct.

Any other idea? Is there anyone facing this same error?

Regards

Hi @Alvaro_RS

Only running office 365 scope will not confirm that the details are correct. Even if you give A B and C in your appID secret and Tenant ID it would still run with out throwing error.

The scope gets executed only when there is an activity inside it

So Please cross verify the same

And do one thing… Run the bot in debug mode and when you get the error open the locals panel and check the inner exception details that might give more information on why the access is denied

Alternately instead of application secret can you try using username and password .We are actually using integrated or username and password and never faced an issue

Cheers

Hi,

I’m Alvaro’s teammate, we have executed the code again and this is the information provided in the exception:

RemoteException wrapping Microsoft.Graph.ServiceException: Code: ErrorAccessDenied
Message: Access is denied. Check credentials and try again.
ClientRequestId: a358a72b-6a81-48d8-b030-1349c88fa180

at Microsoft.Graph.SimpleHttpProvider.d__10.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.BaseRequest.d__40.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Graph.BaseRequest.d__34`1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at UiPath.Shared.Services.Graph.Mail.Extensions.GraphServiceClientExtensions.d__36.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at UiPath.Shared.Services.Graph.Mail.Extensions.GraphServiceClientExtensions.d__22.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at UiPath.MicrosoftOffice365.Services.GraphServiceClientProxy.d__45.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at UiPath.MicrosoftOffice365.Activities.Mail.SendMail.d__54.MoveNext()
— End of stack trace from previous location where exception was thrown —
at UiPath.Shared.Activities.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at UiPath.Shared.Activities.AsyncTaskCodeActivity.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)
image

The thing here is, if we use user and password, are we solving the issue with ‘Basic Authentication’ deprecation?

It is supposed that we have to use AppIdAndSecret or certificate.

Moreover, client’s IT department required us to use AppIdAndSecret, so we need to solve it by this way.

Regards

Hello!
It worked, someone from IT made some changes and we were able to send the mail. We will try to share the knowledge.
Thanks

1 Like

@dferncas @Alvaro_RS

I believe they changed the permissions from delegated to application permissions. Really bad that I couldn’t see that till now when I skimmed through the screenshots again. Anyways happy that its resolved

Hi Alvaro,

You got the solution or not?

Hi all,

Sorry for the delay but i forgot to update the post.

Finally we get the solution creating a mix of granted permissions between application type and delegated.

So the essential list to be enabled is:

  • Mail.ReadWrite (Application)
  • Mail.ReadWrite (Delegated)
  • Mail.Send (Application)
  • Mail.Send (Delegated)
  • Sites.ReadWrite.All (Application)

Furthermore the IT department included an URI redirection (in Authentication space) to next url: https://login.microsoftonline.com/common/oauth2/nativeclient

I hope that this will be helpful for others.

Regards

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