Skip to main content

Notifications

Power Automate - Building Flows
Answered

Automating Email Responses and SharePoint Updates in Power Automate

(0) ShareShare
ReportReport
Posted on by 56

Hello Power Automate Community,

I’m currently working on building an automated workflow that responds to incoming emails and updates a SharePoint list based on the sender's email. The objective of the flow is to streamline communications by sending automatic replies and tracking interactions in a SharePoint list. Here’s an overview of my flow and the specific problem I’m encountering.

Flow Objective: The goal is to create a flow that:

Triggers when a new email arrives in the inbox. and for SharePoint using Get Items without any filter query as checking for all SharePoint list items.

Checks if the sender’s email is already recorded in a SharePoint list. Condition : length(body('Filter_array')) is greater than 0

If the sender is not found in the SharePoint list, sends an auto-reply and adds the sender's email to the list.

If the sender is found in the SharePoint list, checks the timestamp of the last interaction (recorded in the list). If more than 2 hours have passed since the last email, sends an auto-reply and updates the timestamp; otherwise, cancels the flow.

First Compose:  sort(body('Filter_array'),'LastSentTimestamp','desc')

Second Compose:  first(outputs('Compose'))

Condition: addHours(outputs('Compose_2')?['LastSentTimestamp'], 2) greater than utcNow()

Flow works fine for first time email. It sent email and also add records to SharePoint. But when new email arrives and records already exists in first sort it throw error

 
Please help me to resolved this issue. 
 
  • Verified answer
    sandeep_angara Profile Picture
    sandeep_angara 144 on at
    Automating Email Responses and SharePoint Updates in Power Automate
     
    The sort expression was wrong. The expression doesn’t accept a third parameter. For you to sort the array in descending order try the below expression:

    reverse(sort(body('Filter_array'),'LastSentTimestamp'))
     
    This will sort the array in ascending order and then reverses the order making it descending.
     
    If this helps, mark this as an answer. Else let me know how it goes.
     
    Thank you.
  • Personallearn Profile Picture
    Personallearn 56 on at
    Automating Email Responses and SharePoint Updates in Power Automate
    Here I am also sharing run history of flow for existing email where flow failling. Please help me to resolved problem.
    Output of Filter Array: 

    [

      {

        "@odata.etag""\"1\"",

        "ItemInternalId""2",

        "ID"2,

        "Title""xyz@cont.com",

        "LastSentTimestamp""2024-11-29T05:48:59Z",

        "RecipientEmail""abc@cont.com",

        "Modified""2024-11-29T05:48:59Z",

        "Created""2024-11-29T05:48:59Z",

        "Author": {

          "@odata.type""#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",

          "Claims""i:0#.f|membership|abc@cont.com",

          "DisplayName""ABC",

          "Email""abc@cont.com",

          "Picture""https://cont.sharepoint.com/sites/TestSite/_layouts/15/UserPhoto.aspx?Size=L&AccountName=abc@cont.com",

          "Department""Applications",

          "JobTitle"null

        },

        "Author#Claims""i:0#.f|membership|abc@cont.com",

        "Editor": {

          "@odata.type""#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",

          "Claims""i:0#.f|membership|abc@cont.com",

          "DisplayName""abc",

          "Email""abc@cont.com",

          "Picture""https://cont.sharepoint.com/sites/TestSite/_layouts/15/UserPhoto.aspx?Size=L&AccountName=abc@cont.com",

          "Department""Applications",

          "JobTitle"null

        },

        "Editor#Claims""i:0#.f|membership|abc@cont.com",

        "{Identifier}""Lists%252fAutoReply%2blist%252f2_.000",

        "{IsFolder}"false,

        "{Thumbnail}": {

          "Large"null,

          "Medium"null,

          "Small"null

        },

        "{Link}""https://cont.sharepoint.com/sites/TestSite/_layouts/15/listform.aspx?PageType=4&ListId=5950d4a3%2Da615%2D4dda%2D8090%2D49eb8c2ec85e&ID=2&ContentTypeID=0x0100C08C41F723E6B040AF792ABE6AEB8D4D00FECBE6064B3A6F42890CBCCEFE5D5919",

        "{Name}""xyz@cont.com",

        "{FilenameWithExtension}""xyz@cont.com",

        "{Path}""Lists/AutoReply list/",

        "{FullPath}""Lists/AutoReply list/2_.000",

        "{HasAttachments}"false,

        "{VersionNumber}""1.0"

      }

    ]

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard