Saved mail attachments from Outlook are duplicated

Hi!

I’m writing a program to read my emails and save the attachments to a folder. Each email I’m scanning has a reference number at the end of the subject (e.g. ‘Satisfaction Survey (Ref: 84jd93sa01192cd9d)’). I’m planning to download the attachments to a folder and rename them to ‘(ref. no.) - (original attachment name)’. I’ve already done this, but I’m facing the issue where multiple attachments don’t download correctly. It’ll download all the attachments twice except the last one. And the duplicates are not renamed.

Here is a screenshot of my workflow:

Any help is appreciated, thank you!

@kartistenn Can you show us How the files were downloaded? and also can you show in a Screenshot how you wanted the files to be downloaded as ?

Hi, so my files downloaded is like this:


The circled images are duplicates, they aren’t named properly either.

Here is the first part of my workflow, where I grab the mail from outlook. How I saved the files is under the for each loop in attachments (initial topic screenshot)

If you’d like I can attach my workflow too

@kartistenn Is it Processing the Same Email with the Same Ref No. Twice, Is that why you’re getting Duplicate images, because it is processed twice?

is there a way that I can check if it’s processing it twice?

@kartistenn That depends on the Ref No. that you are using , If it is Unique for Different Attachments in the mail, then we can consider it as a way to Solve it.

Okay so, different emails have different Ref no.s
So let’s say:
Email Ref 1 (one attachment)
Email Ref 2 (three attachments)

So in my folder the images will be named
‘1 - image_name.jpg’
‘2 - image_name.jpg’
‘2 - image_name.jpg’
‘2 - image_name.jpg’

Whatever attachment in the same email will have the same ref no. at the front

@kartistenn Ok, But Will these 4 Attachments contain duplicates? Are all the “2-image_name.jpg” files are duplicates in your case?

2 - image_name.jpg are not duplicates as their file names are different. The ref no is the same.


It works correctly except that there are duplicates without the ref no. I want to get rid of the duplicates in general

@kartistenn Then i guess you can First filter the Mail messages having unique Ref No. , Then it will process only those Ref No.s which are different

I’ve figured out why there were duplicates. The download attachment downloads all attachments at once. Looping it the number of attachments there are redownloads the attachments again, causing duplicates.

1 Like

@kartistenn So is the problem Solved? :sweat_smile:

1 Like

Yep it is! And I realised that the issue was that I put the save attachments inside the attachment for each loop which would save the attachments over and over

2 Likes

@kartistenn Good Going :smile:

1 Like

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