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 / Add email's subject na...
Power Automate
Answered

Add email's subject name to the downloaded attachment

(0) ShareShare
ReportReport
Posted on by 50

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hi community,

 

Anyone who knows how to do this would you please help me?

I am using PAD free version. Here is the flow:

キャプチャ.PNG

I have retrieved all the unread emails in the RetrievedEmails list. The attachments are downloaded into the targeted folder.

By specifying its property I am able to get the email's subject:

 ・RetrievedEmails[count].Subject

Attachment file's current path:

 ・RetrievedEmails[count].Attachments[count]

Attachment file's current name:

・RetrievedEmails[count].Attachments[count].NameWithoutExtension

 

*count is variable

*there could be more than one attachment

 

When RenameFiles and an error appears saying file name cannot be changed.

I have tried Display Message to see if variable NewAttachmentName works and it does display the right subject name.

For some reason when used in RenameFiles it didn't work.

 

Below is the error detail:

 

---

Correlation Id: 8186355a-d95b-46a8-901d-88fa66876497

The given path's format is not supported.: Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.ActionException: Can't rename file ---> System.NotSupportedException: The given path's format is not supported.
at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)
at Microsoft.Flow.RPA.Desktop.Modules.File.Actions.RenameFilesAction.Execute(ActionContext context)
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.File.Actions.RenameFilesAction.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)

---

 

Anyone knows the reason for this error?

 

I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @yiyi 

     

    Rename files expects a file path for which file has to be renamed. 

     

    In you case you are renaming the file name from email properties which is not accepted by that action.

     

    Since Retrive email messages from outlook action has already downloaded the attachment to required folder if you have provided that folder path, Then what you can do is assuming one file in the folder path everytime, you can rename the file present in folder path accordingly with subject of email as file name 🙂

     

    Hope this helps !

    Mark it as solution if it resolves your query !

     

  • yiyi Profile Picture
    50 on at

    Hi @Nived_Nambiar 

    Thank you for pointing out that.

    It's true I need to insert file path into "file to rename". I have modified that. Thank you!

    It is interesting that when I changed the rename scheme to "add text" and just randomly enter "a" into "text to add",

    it works, but not with the variable "NewAttachmentName"

    Why is that?

     

     

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

    Hi @yiyi 

     

    I did not get your question, could you please clear on that ?

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Instead of trying to rename %RetrievedEmails[count].Attachments[count].NameWithoutExtension% use %RetrievedEmails[count].Attachments[count]% to rename it. 

     

    %RetrievedEmails[count].Attachments[count].NameWithoutExtension% stores the file name only, it does not contain the path to the file. %RetrievedEmails[count].Attachments[count]% will store a variable of type File, that contains various properties including the file path. This will be accepted by the Rename file(s) action.

     

    As for the %NewAttachmentName%, please note that any characters that Windows do not accept in file names should be removed from the subject text first. Please use a Replace text action on %NewAttachmentName% 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: NewFileName TextToFind: $'''[<>:\"/\\\\|?\\*]''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''%' '%''' ActivateEscapeSequences: False Result=> NewFileName

    This will replace all of those characters with a whitespace. 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.

     

  • yiyi Profile Picture
    50 on at

    Thank you Agnius!

    It was because my subject title had : colon in it.

    Do you mind telling me when replacing the characters with whitespace, why do you use %' '% instead of just inserting a space, or ' '? 

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    A simple whitespace will not be accepted by PAD. And doing ' ' would include the single quotes in the output. %" "% is the correct way to do it for a whitespace and %""% is the correct way to replace it with nothing. 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 997

#2
Valantis Profile Picture

Valantis 810

#3
Haque Profile Picture

Haque 642

Last 30 days Overall leaderboard