[RPA] Using The Microsoft Office 365 Activity For Sending Emails in UiPath

Level of Difficulty: Beginner.

This post will assist in using the Microsoft Office 365 Activity, specifically for sending emails with attachments, in UiPath.

What are the steps?

The steps that we will be following are:

  1. Follow the link on how to create an App Registration on Azure
  2. Get the Application ID and Tenant ID from Azure
  3. Install the UiPath.MicrosoftOffice365.Activities library
  4. Add a “Microsoft Office 365 Scope” Activity
    1. Configure the “Microsoft Office 365 Scope” activity
  5. Add a “Send Mail” Activity
    1. Configure the activity
  6. Add an “Assign” Activity
    1. Assign the files in the directory to a variable
  7. Add an “Assign” Activity
    1. Assign the converted attachments variable to IEnumerable<String>
  8. Add IEnumerable<String> variable to the “Send Mail” activity’s AttachmentCollections property

Deep Dive

Let’s dive deeper into the steps listed above.

Getting the Application ID From Azure

Once you have logged into Azure (https://portal.azure.com/), go into the Azure Active Directory:

Select App registrations and then search for your application. Click on your application when it appears.

Copy the Application ID and the Tenant ID and keep it for later use, when configuring the Microsoft Office 365 Scope:

Now that we have our info from Azure, let’s get started in UiPath.

Install the UiPath.MicrosoftOffice365.Activities library

Create a new UiPath Process, add a sequence to the Main.xaml file and click “Manage Packages” as seen below:

Ensure that focus is on “All Packages” when searching for UiPath.MicrosoftOffice365.Activities.

Select the UiPath.MicrosoftOffice365.Activities library and click on the Install button. After clicking the install button, click on Save and Accept when prompted:

Now that we have the library installed, we can wire our process up to use the MS O365 capability.

Add a “Microsoft Office 365 Scope” Activity

Search for “Microsoft” in the Activities panel and drag the “Microsoft Office 365 Scope” over into the Sequence sitting in the Main.xaml file:

Configure “Microsoft Office 365 Scope” Activity

Ensure that you configure the following properties correctly:

  • Application ID: Application ID obtained from Azure
  • Authentication: Interactive token should be the default and easiest to use, however, it would depend on the security level that is applied to your user on the app registration
  • Services: For sending and reading mails, the Mail service should be selected
  • Tenant ID: Tenant ID obtained from Azure

In the activity pane, find the “Send Mail” activity (Integrations > Office 365 > Outlook) and drag it into the Microsoft Office 365 Scope:

Configure the Send Mail properties as follows:

  • Body: The text that should be included in the email body
  • Subject: The subject that should appear in the email subject
  • From: The email address that the mail should be sent from
  • To: The email address (or email addresses) that the mail should be sent to
  • AttachmentsCollection:
    • {} if there are no attachments
    • IEnumerable String variable that contains the paths of the attachments if there are attachments

The other properties may be configured and adjusted as necessary.

Adding Attachments From Folder

In a case where there are files in a folder that need to be attached, add an “Assign” activity. Create a variable (of Type String[]) named attachments and use the assign activity to assign it to System.IO.Directory.GetFiles(“\Attachments”)

Since the Send Mail activity accepts the attachments collection as the IEnumerable<String> type, the attachments variable needs to be converted from an array of string to an IEnumerable of string. This can be done by grabbing another “Assign” activity and using it to assign a new variable, named attachmentEnumerable (of type IEnumerable<String>) to attachments.AsEnumerable().

Now add the attachmentEnumerable variable to the AttachmentsCollection property of the “Send Mail” activity.

The final process should look like this:

And that’s it folks! Give it a run and feel free to drop a comment about how it turns out.

The above solution is available at on Github

If you have any questions, issues or feedback, drop a comment below or reach out to jacqui.jm77@gmail.com

Published by Jacqui Muller

I am an application architect and part time lecturer by current professions who enjoys dabbling in software development, RPA, IOT, advanced analytics, data engineering and business intelligence. I am aspiring to complete a PhD degree in Computer Science within the next three years. My competencies include a high level of computer literacy as well as programming in various languages. I am passionate about my field of study and occupation as I believe it has the ability and potential to impact lives - both drastically and positively. I come packaged with an ambition to succeed and make the world a better place.

8 thoughts on “[RPA] Using The Microsoft Office 365 Activity For Sending Emails in UiPath

  1. Getting error when assigning attachment to system.IO.Directory(“”) as cannot assign from type System.String[] to “System.String” in Assign activity.
    Attachment variable is of type String.
    Also, when I type email address in To: “something.something.org” it throws error and same with body and subject.

    Please advice.


    1. Hi there. Thanks for reaching out.

      For the ‘To’ field, try enclosing it with “{}” – {“something@something.org”, “something@something1.org”}

      What is the type of the variable you are trying to assign system.IO.Directory(“”) to? Could you provide a screenshot, please?

      When assigning the subject and body, string variables should work.


  2. Is this for Attended RDA or Unattended RPA…?
    “Follow the link on how to create an App Registration on Azure”….I do not see a Link anywhere..?


Leave a Reply to Jacqui Muller Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: