web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Connecting Outlook Fla...
Power Automate
Unanswered

Connecting Outlook Flagged Emails to Planner Tasks

(1) ShareShare
ReportReport
Posted on by 203

I am looking to link flagged emails in Outlook 365 to Planner tasks.  The sample Flow "Create planner tasks for flagged emails in Office 365" creates a Planner task from a flagged Outlook email, however upon completing the Planner task, the associated Outlook task remains open.  Therefore, I am attempting to extend this flow to capture the Outlook messageId within the Planner task, and then create a second Flow that triggers upon completion of the Planner task, completing the associated Outlook task.  

 

My initial flow:

Flow1-PlannerTaskWithOutlookReference.png

 

Can someone help me with the code to extract the string after "OutlookMessageId="so that the second Flow will be able to use it to find the associated Outlook task?

 

Thanks,

Jim

Categories:
I have the same question (0)
  • JimSutt Profile Picture
    203 on at

    Alternatively, if there is a cleaner way to capture the Outlook messageId within the Planner task, I'm very open to suggestions.

  • Verified answer
    v-litu-msft Profile Picture
    on at

    Hi @JimSutt,

     

    Your method is brilliant, I have created a similar Flow with your first Flow, and then I create the second Flow to get the OutlookMessageId, you can create second flow following these steps:

    split(body('Get_task_details')?['description'],decodeUriComponent('%0A'))[0]
    split(outputs('Compose'),'MessageId=')[1]

    Annotation 2019-10-18 111627.png

    Run result:Annotation 2019-10-18 111427.png

    After you get the OutlookMessage ID, you can use it to get the original email.

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • JimSutt Profile Picture
    203 on at

    Hi @v-litu-msft ,

    Thank you so much for your detailed response and kind words! I don't fully understand your two split() commands, but I attempted to use them as you instructed. I was unable to get the Outlook Task and I tried several things to update both my first Flow and your instructions. In every case, the job still failed.

    My first assumption in viewing your split() code: I assume the code will split Planner task Description field using 'MessageId=' as a delimiter. Therefore, in the first flow, I moved the Outlook message Id in the Planner task Description to the end (see screenshot):

     

    Flow1-PlannerTaskWithOutlookReference-UpdatedDescription.png

     

    Flow2:

     

    Flow2-CheckPlannerTaskForString.png

     

    and 

     

    Flow2-GetOutlookMessageIdFromPlannerTask.png

     

    *Note: I updated your second split() to use 'OutlookMessageId='. If my first assumption is accurate, then this update is not needed but the result would be the same.

     

    Assumption #2: The OutlookMessageId can be used to find the associated Outlook Task created when the Outlook email was flagged prior to triggering Flow1.

     

    Flow2-GetOutlookTask.png

     

    When I initiate Flow2, if fails due to a syntax error at Get Task. Either my Assumption #2 is wrong, or Outputs from Compose_2 is not correct.

  • v-litu-msft Profile Picture
    on at

    Hi @JimSutt,

     

    Yes, the  'MessageId=' is a delimiter.

    Sorry, I don't know you are using the Outlook task, the task ID is not the message ID, if you input the Message ID to get task, it could not found the task.

     

    I guess you may need this trigger When a task is added:Annotation 2019-10-21 172028.png

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • JimSutt Profile Picture
    203 on at

    Hi @v-litu-msft ,

    I think I am confused as to how Outlook categorizes flagged emails.  My desired workflow is as follows:

    1. Outlook:  Manually flag email for follow-up

    2. Flow:  Automatically generate a Planner task from the flagged email

    3. Planner:  Manually update the task when completed

    4. Flow: Automatically mark the Outlook flagged email as complete

     

    In Flows "Add an action" dialog under "Office 365 Outlook" I do not see an option to update/mark the email flag as complete.  Therefore, I assumed that Outlook created a Outlook Task from the flagged email.  I appear to be incorrect.  Is there a way to mark the flagged email as complete via Flow?

     

  • JimSutt Profile Picture
    203 on at

    Hi @v-litu-msft 

    I believe I found the Flow action needed:  Office 365 Outlook - Flag Email.  However, when I attempt to get the Outlook email from the MessageId that I stored in the Planner Task Description, I get a 400 error.  

     

    Error details:  Bad Request - Error in query syntax.
    clientRequestId: 01432ba0-69de-4f94-886f-10bd089dd1ae
    serviceRequestId: 3d57f561-4a7a-4050-8b61-fca5de791add

     

    Flow2-GetOutlookEmail.png

     

  • JimSutt Profile Picture
    203 on at

    @v-litu-msft 

    I've successfully been able to get the flow to work!  However, it only works when I embed the email message ID in the first line of the Planner Task Description field.  Can you suggest a modification to your logic in Compose_1 that will take all lines of the description field?  Per my updates on 10/18 of this thread, I moved the email message ID to the end of the Planner Task Description field to reduce the chance it would be modified by the user.  

  • Verified answer
    JimSutt Profile Picture
    203 on at

    Since I'm referencing the Outlook MessageId at the very end of the Planner Task Description field, I combined the two Compose sections into one with the following expression:

     

    split(body('Get_task_details')?['description'],'OutlookMessageId=')[1]

    Everything works! 

    I now have two flows:  one to automatically generate Planner tasks from flagged Outlook emails, and one to mark flagged Outlook emails as completed when the linked Planner task is completed.

     

    Thank you @v-litu-msft for all your assistance!

     

     

  • Gleslie611 Profile Picture
    2 on at
    Hi there

    Sorry, would I be able to get the full flow to capture flagging an email, pushing to planner then on completion of planner task, mark flagged email as complete ??? Many thanks in advance
  • Verified answer
    JimSutt Profile Picture
    203 on at

    Hi @Gleslie611 

    The following is my complete flow.  Note this flow does NOT include attachments from the email.  While I haven't implemented it, if you want to include attachments, you will have to integrate the solution from the following URL into this flow

     

    https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Create-Planner-Task-and-Include-Attachments-From-Outlook-Email/ba-p/245121  

     

    Flow 1:  Create Planner Task from Flagged Email

    Flow1-Overview1.png

    Flow1-Overview2.png

    In the Title field, expression is:

    if(empty(triggerOutputs()?['body/Subject']),'Task for flagged email',substring(triggerOutputs()?['body/Subject'],0,min(length(triggerOutputs()?['body/Subject']),255)))

     

    Flow1-Overview3.png

     

    Flow 2: Complete Flagged Email when Planner Task is completed

    Flow2-Overview1.png

    Flow2-Overview2.png

    Flow2-Overview3.png

    Expression in the Compose element:  

    split(body('Get_task_details')?['description'],'OutlookMessageId=')[1]  

     

    *Note:  In the Condition element, if no, there is no further action.  

     

    Hope this helps!  It's messy to store the Outlook MessageId in the body of the Planner task, but there's currently no fields to link them. 

     

    -Jim

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard