web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / rename attachments to ...
Power Automate
Unanswered

rename attachments to subject line using power automate desktop

(0) ShareShare
ReportReport
Posted on by

hi all

 

does anyone know if it possible to update an email attachment name to the subject line using power automate desktop. I can see it can be done with flows but i have to use power automate desktop. 

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @ketanranchhod 

     

    Use this flow design for understanding 

     

    Nived_Nambiar_0-1695869809853.png

     

    1) First step is to launch the outlook 

    2) retreive the email messages using retrieve email messages from outlook action along with passing attachment download path as so that flow can download the files to a specific location

    Nived_Nambiar_1-1695869899715.png

     

     

    3) Now loop through email and then check if attachments are associated with the email using below expression 

    %Mail.Attachments.Count%<>0 

    Nived_Nambiar_2-1695869952060.png

     

    if the condition is True:

    Then rename the file /attachment with subject line of email. I am assuming that one attachment is present with a single email in my current flow

    Nived_Nambiar_3-1695870005232.png

     

    If there are multiple associated with single email, use the below approach then

    Nived_Nambiar_4-1695870231982.png

     

     

    Hope it helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    What @Nived_Nambiar  suggested there is pretty much the essence of it. There are two things to note though:

    1. You might want to handle all attachments, and not only the first one. An email can have more than one. Even the images in an email signature are considered to be an attachment. So, inside the loop for email messages, you might also want to have an extra loop for attachments for each message.
    2. You might want to sanitize the subject text to remove any special characters that are not valid in Windows system file names.

    To handle point no. 2, use Replace text with regular expressions to replace the following characters:

    • < (less than)
    • > (greater than)
    • : (colon)
    • " (double quote)
    • / (forward slash)
    • \ (backslash)
    • | (vertical bar or pipe)
    • ? (question mark)
    • * (asterisk)

    You can do it via a single Replace text action to replace it all with a whitespace or an underscore or something. You can copy the following code to your PAD designer to have the action inserted automatically:

    Text.Replace Text: Email.Subject TextToFind: $'''[<>:\"/\\\\|?\\*]''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''%' '%''' ActivateEscapeSequences: False Result=> NewFileName

    This will replace all of those characters with a whitespace and store the output in a variable called %NewFileName%. Please use this before your Rename file(s) action.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

     

     

  • VIncent_AZK Profile Picture
    25 on at

    Hi, First of all many thanks for your solution. It is very helpful!

    I felt the key part to the solution is the "%Mail.Attachments.Count%<>0 ". This looks like a coding language whic I don't know i.e. why is . attachemnt.count = counting how many attachement..  and why is .mail.subject = subject of the email. 
    Could you advise what is the language?  Is this Dax language ?

     

  • VIncent_AZK Profile Picture
    25 on at

    Hi, First of all many thanks for your solution. It is very helpful!

    I felt the key part to the solution is the "%Mail.Attachments.Count%<>0 ". This looks like a coding language which I don't know

    i.e. why is . attachment.count = counting how many attachment.. 

    and why is .mail.subject = subject of the email. 

    and why is %mail.attachments[0]% =  those mails has no attachment? 


    Could you advise what is the language?  Is this Dax language ?

    (so far I only know how to write such things in excel fomulas.)

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 273 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 235

#3
David_MA Profile Picture

David_MA 172 Super User 2026 Season 2

Last 30 days Overall leaderboard