cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
karlh
Level: Powered On

Getting an email address out of planner body

I'm fairly new to flow and wanted to extract an email address out of a planner tasks body. They body always looks the same. The very first row always looks like his:

 

Contact: something@whatever.com (can vary in length)

text text text

 

I would like to send out an email if the task is closed to the mail address in the first row. How could I achieve this?
This is what I've tried so far and it's not working at all:

substring(body('get_task_details')?['description'], 10,lastIndexOf(body('get_task_details')?['description'],))
 
But I can not quite wrap my head around it yet, it looks like this thus far:
 
I appreciate your help!
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Getting an email address out of planner body

Hi @karlh ,

 

Have you figured out a solution for this issue?

 

Please take a try with the following code to see if it will work for you:

 

substring(body('Get_task_details')?['description'],add(indexOf(body('Get_task_details')?['description'],'contact'),8),sub(lastIndexOf(body('Get_task_details')?['description'],'.com'),4))

 

I have made a test and it is working fine.

1.PNG

 

Best regards,

Mabel

 

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

View solution in original post

5 REPLIES 5
Dual Super User
Dual Super User

Re: Getting an email address out of planner body

@karlh 

If all email addresses ends with .com, you can use the following

lastIndexOf(body('get_task_details')?['description'],'.com')

Hope this helps





If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!





Dual Super User
Dual Super User

Re: Getting an email address out of planner body

Hi again

As an alternative approach, you can use replace() and indexof() instead

 

Step #1: replace 'Contact: ' (including the space separator) by '' (empty)

Step #2: use indexof() to find the first space (' ')

Step#3: use substring to extract the email address, starting from 0, taking the result from indexof() as the target length.

 

Hope this helps

 

 





If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!





karlh
Level: Powered On

Re: Getting an email address out of planner body


@efialttes wrote:

@karlh 

If all email addresses ends with .com, you can use the following

lastIndexOf(body('get_task_details')?['description'],'.com')

Hope this helps



Thank your for the response!

 

This came back though because it tried to send the message to "22" instead of the mail address, I'm assuming because he's counting the characters before ".com"?

{

"status": 400,
"message": "One or more recipients are invalid.\r\nclientRequestId: 5a8df2c4-07b3-4acc-b634-00a0cd9906c3\r\nserviceRequestId: 67781085-ed45-44af-9e8d-ac2b29f1fc40",
"source": "office365-we.azconn-we.p.azurewebsites.net"
}

 

 

Edit: Oh sorry, I get it now > will try tomorrow and report back

Community Support Team
Community Support Team

Re: Getting an email address out of planner body

Hi @karlh ,

 

Have you figured out a solution for this issue?

 

Please take a try with the following code to see if it will work for you:

 

substring(body('Get_task_details')?['description'],add(indexOf(body('Get_task_details')?['description'],'contact'),8),sub(lastIndexOf(body('Get_task_details')?['description'],'.com'),4))

 

I have made a test and it is working fine.

1.PNG

 

Best regards,

Mabel

 

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

View solution in original post

Highlighted
karlh
Level: Powered On

Re: Getting an email address out of planner body

Thank you so much, you helped a ton!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users Online
Currently online: 236 members 5,034 guests
Please welcome our newest community members: