Skip to main content

Notifications

Community site session details

Community site session details

Session Id : nzF5aLecHKV/nsgXHI0hm0
Power Automate - Building Flows
Answered

Extracting Data from an email to create a calendar event

Like (0) ShareShare
ReportReport
Posted on 5 Apr 2023 10:15:30 by 20

I am very new to this and am trying to work my way around PowerAutomate. 

 

I would like data to be extracted from an email when it arrives in an inbox. I then want to use that data to create an event in a calendar. 

I have created the "When a new email arrives (V3)'  and then converted the body with the "Html to text" section. 

 

The email body is as follows:

"Please take care, this email is from an external source. 

Do not click on any links or open any attachments unless you are sure you know who the sender is.

 

**** This message is sent from an unmonitored account. Please do not reply. ****

Joe Bloggs has requested Holiday from 19/10/23 to 03/11/23.
The Total time the employee is away is 12 day(s), a total of 84 hour(s).
Joe Bloggs will return to work on 04/11/23.
Please login to https://www.login.xxxxxxxx.xx.xx/xxxxxxxx to approve or reject this request.

This request will be deleted in 20 days if there is no response.

Kind regards."


I would like to extract the following things from this email

Name of the person - Joe Bloggs (will be different each time)

Type of Absense - Holiday 

Date From - 19/10/23 

Date To - 03/11/23

 

Once I have this information I would like to create an event using the data above. 

 

Any help appreciated. 

 

 

  • moreno5 Profile Picture
    20 on 03 May 2023 at 13:54:06
    Re: Extracting Data from an email to create a calendar event

    bump

  • moreno5 Profile Picture
    20 on 14 Apr 2023 at 14:49:11
    Re: Extracting Data from an email to create a calendar event

    Hi @HenWang 

    I am getting some strange results from this. It seems to put in the calendar entry but finishes a day before it should. 

    The follow email was sent....

     

    "Please take care, this email is from an external source. 

    Do not click on any links or open any attachments unless you are sure you know who the sender is.

     

    **** This message is sent from an unmonitored account. Please do not reply. ****

    Jane Wright has requested holiday from 10/06/23 to 21/06/23.
    The Total time the employee is away is 7 day(s), a total of 56 hour(s).
    Jane Wright will return to work on 22/06/23
    Please login to https://www.login..co.uk to approve or reject this request.

    This request will be deleted in 20 days if there is no response.

    Kind regards."



    The image below shows the entry in my calendar. 

    moreno5_0-1681483454611.png

    As you can see it ends on 20th instead of 21st. 

     

    This is the final output in the flow which looks fine. 

    moreno5_1-1681483648407.png

     

    Do you know what is going on? 

     

    thanks, 



  • moreno5 Profile Picture
    20 on 11 Apr 2023 at 10:58:21
    Re: Extracting Data from an email to create a calendar event

    Thanks, that worked a treat! 

  • HenWang Profile Picture
    Microsoft Employee on 11 Apr 2023 at 09:52:17
    Re: Extracting Data from an email to create a calendar event

    Hi @moreno5 ,

     

    Below formula would help:

    HenWang_1-1681206642663.png

     

    In compose 2:

    concat(split(outputs('Date_from'),'/')[1],'/',split(outputs('Date_from'),'/')[0],'/',string(20),split(outputs('Date_from'),'/')[2])
     
    In compose 4:
    formatDateTime(outputs('Compose_2'), 'yyyy-MM-ddTHH:mm:ss')
     
    Actually you need to do the change also for the "Date to" value because I didn't notice that you are using the date format which can not be recognized by power automate flow.
     
    Hope this will solve the problem.
     
    Best Regards,
    Hen Wang
  • moreno5 Profile Picture
    20 on 11 Apr 2023 at 08:59:37
    Re: Extracting Data from an email to create a calendar event

    @HenWang Thanks for your prompt reply. 

    I get the following error message when doing this: 

     

    "Unable to process template language expressions in action 'Compose_3' inputs at line '0' and column '0': 'In function 'formatDateTime', the value provided for date time string ' 25/01/24 ' was not valid. The datetime string must match ISO 8601 format.'."

  • HenWang Profile Picture
    Microsoft Employee on 11 Apr 2023 at 08:52:29
    Re: Extracting Data from an email to create a calendar event

    Hi @moreno5 ,

     

    No need to create new variable to hold the value. You can use below formula to format the date value:

    formatDateTime(outputs('Date_from'), 'yyyy-MM-ddTHH:mm:ss')

     

    HenWang_0-1681203083117.png

     

    For example:

    formatDateTime('03/15/2018 12:00:00', 'yyyy-MM-ddTHH:mm:ss') // Returns '2018-03-15T12:00:00'.

     

    More information about this formula:

    Reference guide for expression functions - Azure Logic Apps | Microsoft Learn

     

    Best Regards,

    Hen Wang

  • moreno5 Profile Picture
    20 on 07 Apr 2023 at 15:08:28
    Re: Extracting Data from an email to create a calendar event

    Thank you @HenWang, it worked brilliantly. 

    I am now trying to create a calendar event using the data we have split. It looks like to do so I will need to convert the date to a date that PowerAutomate understands. Do I need to initialise a variable? 

    How can I convert both "date from" and "date to"? 

     

    Currently it is DD/MM/YY and I need to convert it to YYYY-MM-DDTHH:MM:SS

     

    Thanks in advance

  • Verified answer
    HenWang Profile Picture
    Microsoft Employee on 07 Apr 2023 at 03:40:42
    Re: Extracting Data from an email to create a calendar event

    Hi

     

    Please follow below formulas to get the value you want:

     

    I copied the example from your description and paste them in “Compose” action;

    HenWang_0-1680838777740.png

     

     

     

    In my Compose 3 action, below formula will return this text:

    Formula:  split(outputs('Compose'),'.')[4]

     

    Text:

    ****

    Joe Bloggs has requested Holiday from 19/10/23 to 03/11/23

     

     

    HenWang_1-1680838777741.png

     

     

     

     

    The name of the person formula:

     

    slice(split(outputs('Compose_3'),'has')[0],7)

     

    Type of absence:

     

    split(split(outputs('Compose_3'),'requested')[1],'from')[0]

     

    HenWang_2-1680838777743.png

     

     

     

    Date from:

    split(split(outputs('Compose_3'),'from')[1],'to')[0]

     

    Date to:

    split(split(outputs('Compose_3'),'from')[1],'to')[1]

     

    Best Regards,

    Hen Wang

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 87

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 70 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 48 Super User 2025 Season 1

Overall leaderboard
Loading started