Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
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?

 

 

  • Expiscornovus Profile Picture
    31,635 Most Valuable Professional on at
    Re: Remove a URL suffix from a domain name

    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'))
  • annajhaveri Profile Picture
    8,531 Most Valuable Professional on at

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow