debian-server-tools icon indicating copy to clipboard operation
debian-server-tools copied to clipboard

Add PDF support to save_all_attachments.py

Open EmTee70 opened this issue 6 years ago • 5 comments

Line 130 results in .xxx if not .txt if I read it right, I changed it to

if part.get_content_type() == 'text/plain':
    ext = '.txt'
elif part.get_content_type() == 'application/pdf':
    ext = '.pdf'
else:
    ext = '.xxx'

to ensure to get .pdf extension if it is a PDF, I know this is not originally from you, but I just found it here. Thank you.

EmTee70 avatar Nov 29 '19 16:11 EmTee70

Hello @EmTee70 !

Thank you for your comment. What file are you referring to?

This repo contains 1 zillion things.

szepeviktor avatar Nov 29 '19 16:11 szepeviktor

https://github.com/szepeviktor/debian-server-tools/blob/master/mail/extract-attachments/save_all_attachments.py#L130 ??

This code is copied from http://janeelix.com/piers/python/save_all_attachments

Feel free to send a PR!

szepeviktor avatar Nov 29 '19 17:11 szepeviktor

Yes, you are right. I am relative new to GitHub and so I was calling it an issue, it would probably be cool to support all mime types. Put them in an associative array and so... maybe I try to solve this.

EmTee70 avatar Nov 29 '19 18:11 EmTee70

No problem!

Just press the pencil icon (top right) https://github.com/szepeviktor/debian-server-tools/blob/master/mail/extract-attachments/save_all_attachments.py and send your idea in a Pull Request!

szepeviktor avatar Nov 29 '19 18:11 szepeviktor

@EmTee70 Is it okay for me if you write your suggestion here as a snippet.

szepeviktor avatar Dec 02 '19 20:12 szepeviktor