Inkey Solution Logo
banner

Blogs

Use Power Automate to get Name and Email Address in Outlook Online

, September 27, 2024 569 Views

This  Power Automate Flow fetches Name and Email-address of the Person/(s) mentioned in the ‘From’, ‘To’, ‘CC’, ‘BCC’ mappings of the Outlook Online for a user-defined time-period i.e., Start Date and End Date and outputs the data in a Notepad .txt file in Outlook Online to a specific user-defined person email.

What are the input parameters for this Flow?

Start Date : From which date to fetch the Names and Email from.
End Date : Till which date we need to fetch the Names and Email from.
To Email Address : To whom the Output Notepad .txt file is to be mailed. [Can be single or multiple persons.]
Extract Emails only from INBOX Folder? : Whether to fetch data from INBOX folder or all the folders. Note this excludes Junk and Deleted Items folder.
Filter out Emails containing : The names or strings passed here are excluded. Filters are maintained & implemented internally.

What is the output of this flow?

The output is a Notepad .txt file generated and sent on Outlook Online To Email Address mentioned in the Input Parameter of the Flow containing Names and Email Address from user-defined date range: 15-Feb-2024 to 16-Feb-2024. Also mentioned is the execution details of the flow.

Notepad content: [Name and Email Address]

How does this Flow works/ Implementation:

Step by Step Flow:

  • These are the input parameters that are passed in the Trigger Time of the Flow.

  • Setting a Start-Time Variable to note the Total Execution Time.
    Storing utcNow() when the flow starts.

  • Graph API Call to fetch the folder names & its respective Id.
    [Note: the first 1000 folders are extracted, and it is but obvious that any user might not have more than 1000 folders in their Outlook Online.]

  • The Parse JSON steps parse the extracted Folder JSON.
  • Initializing var_AllFoldersId to store all the folder ids in Array format.
  • Initializing var_loopBreaker variable for loop-breaking purpose.

  • The logical condition for step 7 to extract the folder ids are:

Verifying/Testing the URL in GRAPH Explorer.

 

  • Created var_DateDiffInteger: Calculating and storing date difference between the input parameters Start Date and End Date.
  • Created var_ToCcBccArray: To store From, To, CC, BCC values in Arrays.
  • Created var_ToCcBccHolder: To store From, To, CC, BCC Holders for intermediate storing purpose.
  • Created var_ToCcBccAppender: To store From, To, CC, BCC Appenders for appending arrays.
  • Created var_DistinctEmailAddresses: To store distinct Email-Addresses from fetched Names & Emails.

  • Created var_FilterOutValues: Storing values that are passed in the Input Parameters ‘Filter out Emails containing’ which will be excluded in further steps.
  • Created var DateTime: Calculating the date-difference and storing it in variable.

  • To each extracted Folder Data which is stored in var_AllFoldersID,.

We are fetching the Folder-ID in the Compose Step.

In Do-Until Step, until the Date[StartDate + var_DateDiffInteger] is less than StartDate. Also make sure to change the limits of Count = 5000 and Timeout = P4D in Advanced Settings of Do Until Step.

Sending an HTTP Request to fetch the data from Mail Folder where Received date is greater than equal to yyyy-MM-dd 00:00:00 and less than equal to yyyy-MM-dd 23:59:59

Parsing JSON from above step.

Selecting ‘From’, ‘To’, ‘CC’, ‘BCC’ and storing it in var_ToCCBccArray.

Apply to Each Array Element in above Select Step.

    1. Setting var_ToCcBccArray = Union of each element of From, To, CC, BCC
    2. Setting var_ToCcBccArray = concating NAME and EMAILADDRESS among all the details.
    3. Create CSV Table = This step stores the JSON data to text-formatted data.
    4. Setting var_ToCcBccHolder = var_ToCcBccAppender
    5. Setting var_ToCcBccAppender = var_ToCcBccHolder + Create CSV Table

Decrementing var_DateDiffInteger by 1. And this value will be passed and iterated back

Resetting var_DateDiffInteger to its Start Date – End Date

  • Compose: Switching the case of the Names and Email-addresses to lowercase and replacing the newline characters with “;”
  • Splitting upon “;” to create an Array.
  • Union same output 2 times which is a method to fetch distinct records of array, and then sorting the array.
  • Storing the distinct Names and Email-addresses in var_DistinctEmailAddresses.

Filtering out unnecessary email and names that were mentioned in the Input Parameter ‘Filter out Emails containing’.

  • Converting the final array to text format and separating it with newline character.
  • Calculation of the Total Time taken to Execute the Flow.
  • Sending the Final Mail to the Recipient.

 

mm

Inkey

INKEY is your solution partner.
Our focus is to deliver you in-time intelligent innovative solutions ("key") for the problems in hand. Maintaining a quality standard right from the inception of a project is our top most priority.

Our team of talented professionals will execute your projects with dedication and excellence. We take ownership and accountability for the effort that goes into meeting our client’s needs.

Years of experience and proven success of delivering innovative custom solutions.

More posts by

Leave a Reply

Your email address will not be published. Required fields are marked *

The maximum upload file size: 2 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Drop file here

Would you like to digitize your business and put it on the cloud?
Do you need clear, concise reports for your organization?