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 / Saving emails onto Sha...
Power Automate
Suggested Answer

Saving emails onto Sharepoint with unique naming

(0) ShareShare
ReportReport
Posted on by 12
Hi all,
 
I currently have a flow which automatically saves emails passing through a mailbox onto Sharepoint.
 
If the email contains an attachment, it will save the attachment and upload it onto Sharepoint as per the naming of the attachment name. (A)
If the email do not contain any attachment, it will save the email content as an eml file and upload it onto Sharepoint. The name of the eml file will be the Subject of the email. (B)
 
does not have any problems as 99.99% of the time the name of the attachments received are always unique and different.
However, there will be certain times where B will have problems especially when the sender reply to the email thread (as the subject will become "RE: abcdefg"). For example, the first eml file saved will be "Subject". When the sender first reply to the thread, the eml file saved will be "RE: Subject". However, when the sender subsequently replies to the thread, the eml file saved will still be "RE: Subject". This naming convention REPLACES the previous eml files saved since the name of the eml file is no longer unique. 

Does anyone have any suggestion on how I can possibly make the naming unique while at the same time retaining the aspect of my flow saving the attachment (A) / content (B) as something that is recognizable (ie. attachment name). Below is a screenshot of my current flow for B. If no = if no attachments.
 
Screenshot 2024-12-09 104912.png
Categories:
I have the same question (0)
  • Suggested answer
    SudeepGhatakNZ Profile Picture
    14,396 Most Valuable Professional on at
    You can add a unique identifier to the filenames. A common approach is appending a timestamp or a GUID (globally unique identifier) to the filename. You can generate  a unique identifier using utcnow()
     
    formatDateTime(utcNow(), 'yyyyMMddHHmmss')
    This generates a timestamp like 20241206153045.
     
    Concatenate the subject with the timestamp to create a unique filename. Use an expression like:
     
    concat('RE-', triggerOutputs()?['subject'], '-', formatDateTime(utcNow(), 'yyyyMMddHHmmss'), '.eml')
     
    Examples

    1. The first email will be saved as Subject-20241206153045.eml.
    2. The first reply will be saved as RE-Subject-20241206154010.eml.
    3. The second reply will be saved as RE-Subject-20241206155020.eml.
  • AC-28110956-0 Profile Picture
    12 on at
     
    Thanks for the suggestion. I just implemented your flow and ran it. However, my sharepoint reflected multiple eml files. Take a look below. I ran your concat file as per your suggestion, except adding the "RE-" part. May I know where did I go wrong?
     
     
     
  • SudeepGhatakNZ Profile Picture
    14,396 Most Valuable Professional on at
    Are you still struggling? Should I take a look at the expression or have you got it sorted?

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard