What is the "best" approach for sending/receiving Microsoft 365 (Outlook) emails for unattended bots?

This might be a very basic question but there seem to be not one obvious answer.

Context: we were using Send Exchange Mail Message in the past with Basic Authentication (username/password) but this has been deprecated now. We then used Send SMTP Mail Message with basic authentication as well - but our IT don’t want to use Basic Authentication anymore plus SMTP doesn’t allow us to read/get emails.

Another option is Send Outlook Mail Message - but this requires Outlook app to be installed and account is configured on the machine where the unattended bot will run. We prefer not to have this dependency.

Next option is Integrations (Gmail and Outlook): Using this, you need to login to the account then request for admin to approve the integration. Now when that is set up, how would that go when it is deployed to a different Orchestrator tenant (deploying from Dev to Prod)? Note I’m referring to Use Outlook 365 activity with the Use Integration Service unticked.

Please feel free to suggest other options.

So what do you use and what do you recommend?

Hello @ticsrobo.au

Sequence
Assign
emailCredentialsAsset = "NameOfEmailCredentialsAsset" // Replace with your Orchestrator asset name
Assign
emailSubject = "Your Email Subject"
Assign
emailBody = "Your Email Body"
Assign
recipientEmail = "recipient@example.com"
Assign
smtpIntegration = "YourOutlookIntegration" // Replace with your Outlook integration name

Use Outlook 365
Properties
IntegrationService = smtpIntegration
MailFolder = “Sent Items”
MailMessage
Subject = emailSubject
Body = emailBody
IsBodyHtml = False
Recipients
To = recipientEmail
Input
EmailAccount = emailCredentialsAsset
Output
SentMessage
Log Message
Message: Email Sent Successfully

Thanks & Cheers!!!

Hi @Kartheek_Battu,

not sure if I understood your reply accurately but Account in Use Outlook 365 is a dropdown. I don’t see where IntegrationService can be specified. It is a checkbox.

Hi @ticsrobo.au ,

There is one more option for Send/Receive email using O365 GraphAPI.

GraphAPI use TenentID & ClientID, so you don’t need username and password for each account to authenticate.

You have to create an App in Azure portal and its one time activity, once it done you are good to go.

The best part is since we are using TenentID & ClientID for authentication, we can run a bot using any machine & any user account, so it will not have dependence with VM account.

Let me know if you need more information about it. Happy to help you.

Thanks
Muthu

Hi @muthuerd, thanks for your suggestion. This is a good approach however it’s a lot complex compared to just using an activity. In addition, if we want the email to come from a specific user, we have to setup the Graph API permission as delegated permission, correct? And with delegated permission, we have to maintain a refresh token or create a workflow that generate the code to be able to get the refresh token and access token. That whole config and token handling makes this complex. Happy to hear your thoughts.

  1. Create an App with the following permission. Reference - Activities - Set up your Microsoft 365 Azure app
  2. Use UiPath.MicrosoftOffice365.Activities package
  3. Use Microsoft Office 365 Scope.
  4. Inside that you can the email account you want to read the email.

Please refer the above steps to read an email using GraphPAI. Only creating an app takes time but its a one time activity.

But activity in studio is straight forward.

Hope it helps you. Let me know if you have any questions.

Thanks
Muthu

Hi @ticsrobo.au

You can also use “Get IMAP Mail Message” activity in UiPath
Ensure that IMAP is enabled on your email server, and you have the necessary server details (server address, port, etc.).

Hope this helps :slight_smile:

Hi @muthuerd, How can I limit the access to specific accounts only? Being able to access any email seems risky.

Hi @ticsrobo.au , you cant restrict access in UiPath, but you can do that in the app

Please referee the Microsoft link to access specific account.

Let me know if you have any questions.

Thanks
Muthu

1 Like

Thanks for all your inputs. So far, I think the best way (although it is relative) to send an email is using the integration service. That is in terms of its flexibility and ease of setup. Will have to wait and see how it performs in Production scenario.

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