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 / 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.
 
Categories:
I have the same question (0)
  • Suggested answer
    SudeepGhatakNZ Profile Picture
    14,394 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,394 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

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

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard