How to create an RPA Flow using OneDrive activities to upload documents
Advanced | 45 Minutes
Overview
This tutorial will show you how to create a basic flow using some of the OneDrive activities. We will create a flow to upload documents/files into a OneDrive folder by first reading them from an Outlook account. We will use For Each File or Folder in combination with Get Files or Folders to upload the documents to an already existing folder.
Note: The combination of For Each File or Folder with Get Files or Folders can also be replaced by Find Files or Folder, as shown in this tutorial: How to Create an RPA Flow Using OneDrive Activities to Download Files.
📋 RequirementsBefore you can start building the flow, you’ll need to:
|
Note : In order to avoid flow failure, user must authorize MSGraph in the RPA Mastermind Dashboard to use Graph related Activities.
Tutorial
1
Open RPA Studio
Open RPA Studio on your machine. If you are not signed in to the Tenant already, you will be asked to sign in before proceeding to the RPA flow designer screens.
2
Create a New Project
- On the Home page of RPA Studio, click Create New Project and specify the following properties in the popup window:
- Name: OneDrive Upload Share
- ProjectLocation:
- Description: OneDrive flow to get the mails from Outlook and upload to OneDrive Folder
- Language: VB (selected by default)
3
Start Flow with Sequence
Start the flow by adding a Sequence block to create a small sub-flow to read the mails from the Outlook account and store the attachments. Drag and drop the Sequence activity from the Activities side panel.
4
Add Get Outlok Emails Activity
In the Activities panel, search for Get Outlook Emails Graph, which allows reading mails from the Outlook Account in MS Office 365. Click on the activity on the design canvas and set up its properties. Create a few arguments to reference the activity properties.
- Note: To use this activity and OneDrive activities, you need to create the OAuth provider MS Office 365 as listed in the prerequisites.
- Select the Include Attachments property.
- Set the Mail Folder Name property to the name of the mailbox folder from where emails will be read. Create an argument called MailFolderName of type string with a default value:
demo. - Select the Mark as Read property.
- For Retrieve Top N Mails, specify
3(or any number). - For Email List, create a variable (not an argument). This variable will store the list of emails read from the Outlook account.
- Create a variable called mailList of type List without any default value.



5
Create a For Each
Create a loop to save an attachment from each read mail by adding a For Each activity with the following settings:
- Set the Type property to Mail (Infor.Activities.Email.Mail) (same as the single object type from the mailList variable).
- Set the Value property to mailList.
In the activity on the Design Canvas, you will see: ForEach item in mailList, where item signifies a single object (mail) in this list of objects.

6
Save attachments by adding sequence
Within the For Each body, add a Sequence
Next, add the Download Email Attachment Graph activity to save the attachment from each of the read mails. Set the following properties:
- For Email, specify Item from the For Each activity.
- For Save Destination, create an argument called attachmentFiles of type string with the default value: C:\RPA\Attachments.
- For File Paths (output property), create a variable called paths of type List<String>.
7
Read Attachments with Get Files directory
Add the Get Files Directory activity, which allows us to read all the attachments stored on the local system. Drag and drop this activity on the design canvas and configure its properties:
- For Path, specify the attachmentFiles variable.
- For Files, create a variable called FileList_attachments of type List<string> without any default value.
8
List file IDs with For Each Files
Next, add the For Each Files or Folders activity to list the IDs of one or multiple folders/files based on the defined query. Configure it with the following settings:
- For Search Keywords, create an argument called OneDriveWrite with a default value of
"Demo_RPA_Onedrive_Write". - For Account, create an argument called AccountMail with a default value of your email.
- For Limit Results, specify
1to find only one folder. - For Results, create a variable called resultID of type String[].
9
Retrieve file with Get File
Add the Get File or Folder activity to retrieve a single OneDrive object based on the provided ID. Configure it as follows:
- For OneDrive Item ID, specify
resultID(0)to retrieve the first item from the array. - For Account, specify the AccountMail argument.
- For Item, create a variable called Folder_OneDrive of type OneDriveItem.
10
Share Created Folder
Add the Share File or Folder activity to share the created OneDrive folder. Configure the following properties:
- For File or Folder to Share property which should contain the id of the OneDrive Item to share specify Folder_Onedrive variable output from Get File Or Folder activity.
- For Grantee permissions select which permissions should a person you share the file with get. You can select between Edit and View.
- For Grantee Type which is the type of the recipient for whom the permission are granted, you can select from dropdown e.g. SpecificPeople, PeopleInOrganization or Anyone
- For Recipients which is the list of people with whom we should share the folder, let’s create the argument
- called reclist of type Array of string, String[] without a default value(s) written between the “{}” e.g. {“natalia.ptaszek@infor.com“, “john.smith@infro.com“}
- For Require sign in select True
- For Send sharing invitations mail select True
11
Upload attachments with For Each
Next we will create a loop which will allow us to upload each of the stored attachment into OneDrive Folder For that we need to add For Each activity and specify the following:
- for Type property as String which is same as a single object type from the FileList_attachements variable
- for value property define FileList_attachements.
- In the activity on Design Canvas You will see the following text “Foreach item in FileList_attachements” the item signify the single object in this example mail within the list of object, here list of file paths
Optionally, add a Sequence activity inside the For Each block.
At the end add Upload File to start uploading the attachments saved in the File directory on the local system and specify the following properties of this activities;
- For File Upload, specify Item from the For Each activity.
- For In Case of Conflict, select Replace.
- For Destination Folder, specify the Folder_OneDrive variable.
- For Destination Path, create a variable called attachementDrive of type OneDriveItem.
Now, the flow is complete and can be run to automatically read the files and upload them to OneDrive.
Activities List
What made this section unhelpful for you?
On this page
- How to create an RPA Flow using OneDrive activities to upload documents