Save All Attachments to All Folders, How to prevent it?

I am trying to save attachments according to their name. Attachments name include customer name information. There are folders which has name customer names. For example one mail has many attachments. with this workflow it saves all attachments to all folder. I just want one folder has one attachments according to a customername. Could you please help me?

Could you upload your workflow (the xaml file) here? It’s hard to see from the image.

Okay, getmailstemp.xaml (25.4 KB)

Thanks! Could you give us an example of the attachment names? Also could you post a screenshot of the Output panel (System Console) after you have run your workflow?

For example this is one of the attachment name ROHM_AND_HAAS_LTD.xlsx and there is a folder name ROHM_AND_HAAS_LTD like that. When I get the attachment name, just crop .xlsx part. Then save attachment path is like that C:\Users\z003tw0h\Desktop\CustomerMasterFolder"+attachmentName+""

When you write the attachmentName to the console, is it correct? E.g. does it says “ROHM_AND_HAAS_LTD.xlsx” or does it says “ROHM_AND_HAAS_LTD” ?

Name is correct. my problem is save attachment activity save all attachment coming with one mail to every spesific folder inside. When i open the folders i can see all of them in evey folder

Ok, sorry my bad. The Save Attachments activity will save all attachments to the specified folder.

So if you have three attachments, lets say USER1.xlsx, USER2.xlsx, USER3.xlsx, your worklfow will save all attachments to folder USER1, USER2 and USER3.

User Filter to save only one file.

Could you please give me an example how to use filter option? Directly file path+filename like that or with another way?

The filter should be in regular expression, but since you want a literal match, you need to escape your string. You can use the RegEx.Escape() to do that. Extract the filename of the attachment (including the extension) and lets call it attachmentFileName. Then create the filter like this:

OneFileFilter = System.Text.RegularExpressions.Regex.Escape(attachmentFileName)

And set the Filter property in the Save Attachments activity:

OneFileFilter is just a string variable.

I believe you should be able to use attachment.Name:
OneFileFilter = System.Text.RegularExpressions.Regex.Escape(attachment.Name)

Thank you, it is worked fine

1 Like

Good to hear! :+1:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.