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

Using the file path to build an email address

Hello,

 

I tried this previously and it wouldn't work due to how the filesystem triggers worked,  but it seems to be possible now. 

I have a personnel folder that contins folders for individuals, so they look like, /Shared Documents/Personnel/First Last/

Inside there there are other folders like HR, Forms, Docs, etc.  I've already got it watching /Shared Documets/Personnel, so if anyone creates or modifies a file in one of the employee sub-folders, it will email the file to a test email address I have.  What I'd like to do is have the email recepient address be filled in based on the file path (our email scheme is first.last@company.com).  So as an example, if someone drops a file into /Shared Documents/Personnel/John Doe/Documents/file.txt, it will use the file path to create john.doe@company.com and put that into the To field.  Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Using the file path to build an email address

 

Hi @sdgewand ,

 

Could you tell us which connector you are using? File System or SharePoint Library?

I used SharePoint Library to illustrate how to get the username contained in the File path.

Use the Split() function to split the File path with "Personnel/" and "/Documents" as the split points, and then get the First last name contained in the File path.

Then combine them into the email address.

Expression reference:

concat(toLower(replace(first(split(last(split(body('Get_file_metadata')?['Path'],'Personnel/')),'/Documents')),' ','.')),'@company.com')

Image reference:

178.PNG

 

Best Regards,

Community Support Team _ Barry
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

3 REPLIES 3
Super User
Super User

Re: Using the file path to build an email address

@sdgewand 

Hi there.  Seems like this is totally possible, what do you have so far?  I think an O365 Get User Profile won't work since you'll need the email address ahead of time, but you might be able to use the Office 365 Users connector action, "Search Users" and use the file path section as the search term.

 

Keep us posted.

-Ed-

 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

Community Support Team
Community Support Team

Re: Using the file path to build an email address

 

Hi @sdgewand ,

 

Could you tell us which connector you are using? File System or SharePoint Library?

I used SharePoint Library to illustrate how to get the username contained in the File path.

Use the Split() function to split the File path with "Personnel/" and "/Documents" as the split points, and then get the First last name contained in the File path.

Then combine them into the email address.

Expression reference:

concat(toLower(replace(first(split(last(split(body('Get_file_metadata')?['Path'],'Personnel/')),'/Documents')),' ','.')),'@company.com')

Image reference:

178.PNG

 

Best Regards,

Community Support Team _ Barry
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
sdgewand
Level: Powered On

Re: Using the file path to build an email address

Thank you!  That worked great.  The only modification I did was that, rather than 'Documents/' I just used '/' to split it, otherwise it included all the sub-folders following the name. 

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!

Top Kudoed Authors
Users Online
Currently online: 439 members 6,078 guests
Please welcome our newest community members: