nickrussler / email-to-pdf-converter

Converts email files (eml, msg) to pdf
https://www.whitebyte.info/publications/eml-to-pdf-converter
Apache License 2.0
281 stars 65 forks source link

Attachments with the same name are being overwritten #69

Closed jesnyder13 closed 5 months ago

jesnyder13 commented 5 months ago

When processing messages with attachments that have the same name, it is overwriting the previous attachment. After it counts the attachments could it append a number to the filename?

2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#345]: Start extracting attachments 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#356]: Found 6 attachments Extract attachments to C:\test-attachments 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#366]: Process Attachment 0 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#405]: Saved Attachment 0 to C:\test-attachments\image.jpg 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#366]: Process Attachment 1 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#405]: Saved Attachment 1 to C:\test-attachments\image.jpg 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#366]: Process Attachment 2 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#405]: Saved Attachment 2 to C:\test-attachments\IMG_1786.jpeg 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#366]: Process Attachment 3 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#405]: Saved Attachment 3 to C:\test-attachments\image.jpg 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#366]: Process Attachment 4 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#405]: Saved Attachment 4 to C:\test-attachments\image.jpg 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#366]: Process Attachment 5 2024.05.30 12:10,042 [MimeMessageConverter.convertToPdf()#405]: Saved Attachment 5 to C:\test-attachments\image.jpg

I end up with the image.jpg file that is listed as attachment 5...

Directory: C:\test-attachments\

Mode LastWriteTime Length Name


-a---- 5/30/2024 12:10 PM 2733408 image.jpg
-a---- 5/30/2024 12:10 PM 367878 IMG_1786.jpeg

nickrussler commented 5 months ago

Fixed in https://github.com/nickrussler/email-to-pdf-converter/releases/tag/2.8.0

nickrussler commented 5 months ago

Please confirm the fix.

jesnyder13 commented 5 months ago

Thank you for looking at this so quickly!

With the fix in place, I now get two of the five attachments with duplicate names. Instead of continuing to increment it starts overwriting at (2).

2024.06.03 10:59,027 [MimeMessageConverter.convertToPdf()#357]: Start extracting attachments 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#368]: Found 6 attachments Extract attachments to C:\test-attachments 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#384]: Process Attachment 0 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#410]: Saved Attachment 0 to C:\test-attachments\image.jpg 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#384]: Process Attachment 1 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#410]: Saved Attachment 1 to C:\test-attachments\image (2).jpg 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#384]: Process Attachment 2 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#410]: Saved Attachment 2 to C:\test-attachments\IMG_1786.jpeg 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#384]: Process Attachment 3 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#410]: Saved Attachment 3 to C:\test-attachments\image (2).jpg 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#384]: Process Attachment 4 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#410]: Saved Attachment 4 to C:\test-attachments\image (2).jpg 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#384]: Process Attachment 5 2024.06.03 10:59,028 [MimeMessageConverter.convertToPdf()#410]: Saved Attachment 5 to C:\test-attachments\image (2).jpg Conversion finished

nickrussler commented 5 months ago

Pushed a fix, can you please try with https://github.com/nickrussler/email-to-pdf-converter/actions/runs/9389728043/artifacts/1572349526 ?

jesnyder13 commented 5 months ago

This time it is perfect.

Thank you!