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

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Compare Email Subject ...
Power Automate
Unanswered

Compare Email Subject and Save Attachment

(1) ShareShare
ReportReport
Posted on by 4
Hello Team,
 
Looking for your support to build the flow which help us to compare and math the email subject and save attachment into SharePoint folder with respective folders.
 
Fo example, if we create a folder in SharePoint with name "A" and user A send email with subject "Invoice Customer A" then if email subject contains username A and save the attachment into folder "A" only. 
Categories:
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
    Compare Email Subject and Save Attachment
    Hi,
     
    would email subject would be in format of Invoice Customer A , Invoice Customer B like that ?....
     
    Just to confirm 
  • Mark Nanneman Profile Picture
    991 Super User 2025 Season 2 on at
    Compare Email Subject and Save Attachment
    IMO, this isn't the best way to do something like this.  You can have multiple people with the same common name, people can mispell names or even just use alternate spellings, people can get married then the name changes, etc.  You really want to have a unique key of some sort, some sort of customer id number to use.
     
    That said you can do what you're saying, you just need to use string manualation actions / expressions in your flow.

    For instance if your subject was "Invoice for Customer John Smith" something like "Trim(Last(Split(<reference to email subject string>,' Customer ')))" would output "John Smith".

    You can then list your root sharepoint folder and filter on items that are folders, and also filter on folders that have the customer name in the folder name to find the customer's folder.

    But, as I hinted before, this would not be a best practice.  Best practice would be to store the customer names in some sort of Database, even a sharepoint list, and give each one a unique id, and use that unique id in your emails.  Your SharePoint list or other database could have the path to their sharepoint folder stored in a column, and you just lookup the customer by their ID from the email, then grab their sharepoint folder path, then save the attachments to that folder.

    Hope that helps!

    If this helped you, please click "Does this answer your question" and give it a like to help others in the community (+ close the ticket)!

    Power Platform Developer | LinkedIn: Mark Nanneman | Blog: Power Stuff  | YouTube: Mark's Power Stuff  
  • MM-15111256-0 Profile Picture
    4 on at
    Compare Email Subject and Save Attachment
    Hi Nived,
     
    Yes, customer names like Invoice Customer A (A = John Smith) & so on. We have more around 60 customers.
  • Suggested answer
    Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
    Compare Email Subject and Save Attachment
     
    Try like as shown in below demo flow
     
    I have created a folder Invoices inside which have many subfolders, each subfolder representing Customer Name as shown below
     
    Now try as per below steps
     
    1. Use trigger when email arrives with below params 
     
    I assume mail subject starts with Invoice Customer.
     
    2. Use filter array to filter the non inline attachments from attachments array as shown below
     
    3. Use Compose action to remove the Invoice Customer sentence to get customer name from mail subject
    Expression used: 
    trim(replace(triggerOutputs()?['body/subject'],'Invoice Customer',''))
     
    4. Now use get files action to check whether the folder with customer name exists in given location
     
    5. using condition - check whether the folder exists or not 
    Expression used: 
    length(outputs('Get_files_(properties_only)')?['body/value'])
     
    6. If condition is True- follow Yes branch
     
    Under Yes branch - do the following
     
    7. use apply to each to loop attachments list 
     
    7.1 - use get attachment to get attachment content
     
    7.2- use create file action to create file 
    The folder path is dynamic to include customer name in path at the end 
     
     
     
    Hope it helps !
     

    Thanks & Regards,
    Nived N

    Stay connected:
    LinkedIn | YouTube | Blogs

    Was this answer helpful?
    If yes, please mark it as the solution by selecting the checkbox in the discussion thread.
    Your feedback motivates me to keep contributing. Thank you!

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

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard