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 / Remove a URL suffix fr...
Power Automate
Unanswered

Remove a URL suffix from a domain name

(0) ShareShare
ReportReport
Posted on by 31

I'm building a flow to save Outlook attachments to a Sharepoint library, but I also need to rename the file based on sender's email address and date. For example, if I receive a PDF attachment from bob@testcompany.com on February 2nd of 2024, I need to name the saved file 'testcompany_2_2_2024.pdf'

 

I've added 2 compose steps to my flow to get the domain name, but can't figure out the regex to remove the domain suffix (.com, .net, etc) from the composed string.

Here's what my steps look like so far:
1. Initialize Variables

SescoDev_6-1704736746995.png

2. Compose Sender and set Sender variable 

SescoDev_7-1704736807466.png

SescoDev_8-1704736832449.png

 

 

3. Compose DomainName and set DomainName variable

SescoDev_9-1704736884291.png

SescoDev_10-1704736916099.png

4. Compose "cleaned" Domain Name (URL suffix removed) and set CleanDomain variable

SescoDev_11-1704736995281.png

SescoDev_12-1704737036473.png

5. Check that attachment is a PDF, then save it to Sharepoint with a filename based on the CleanedDomain and Time/Date of the email

SescoDev_13-1704737137262.png

SescoDev_14-1704737385112.png

My questions are:

1) Is there a better way to get the domain name minus the suffix?
2) What's the best way to reformat the date/time to meet my needs?

 

 

Categories:
I have the same question (0)
  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @SescoDev,

     

    You can use a couple of splits for this. First split on the '@' and only use the second item of the returned split array. After that you can split again on the '.' character. In that case you can use the first item of that second array.

     

    Below is an example expression

    concat(first(split(last(split(triggerOutputs()?['body/from'], '@')), '.')), '_',
    formatdatetime(triggerOutputs()?['body/receivedDateTime'], 'dd_MM_yyyy'))

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard