RealRaven2000 / FiltaQuilla

Adds many new mail filter actions to Thunderbird
http://quickfilters.quickfolders.org/filtaquilla.html
GNU General Public License v3.0
85 stars 15 forks source link

Save the attachment of specific mail to a specific name #61

Open yarn37235 opened 4 years ago

yarn37235 commented 4 years ago

I kindly ask to copy some attachement of specific files (Invoices, normaly as PDF or jpg or doc) to a standarized place (invoice-inbox) on my computer . (This would help me to save a lot of time on those days where I do my accounting). One issue could be, that some suppliers are just sending there invoices as a attachment with always the same name... like always "invoice.pdf". In such case it would be superperfect, if the tool does not simply override the already existing "invoice.pdf" in the invoice-inbox on my computer but if the tool would instead ad a number or better a time stamp to the to be saved attachment.... like "invoice_202007010847.pdf".. I don't need a printing of the email itself, because in 99 % the tax-compatible invoice is a attachment to the email itself. Thank you

RealRaven2000 commented 4 years ago

I kindly ask to copy some attachment of specific files (Invoices, normaly as PDF or jpg or doc) to a standarized place (invoice-inbox) on my computer .

the term "specific files" is super vague. But I guess you can select any specific mails (I presume you mean mails not files) by setting the correct search conditions. If you need something special here that cannot be achieved with standard conditions or those added by FiltaQuilla, you can add that to a separate feature request. Otherwise I would suggest to just come up with a test case, such as "only mails from Fred Flintstone" or "only mails that have the tag 'important' and 'work'" etc.

I think the meat of this request is the saving of attachments in a folder, correct?

One issue could be, that some suppliers are just sending there invoices as a attachment with always the same name... like always "invoice.pdf". In such case it would be superperfect, if the tool does not simply override the already existing "invoice.pdf" in the invoice-inbox on my computer but if the tool would instead add a number or better a time stamp to the to be saved attachment.... like "invoice_202007010847.pdf"..

so at the moment FiltaQuilla uses the interface [nsIFile.createUnique()](https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile#createUnique()) to create / open a file directory (folder) and then appends the normal file name in the FiltaQuilla function SaveAttachmentCallback.

Looking at the source code of the createUnique() function we find the following comment:

     *  createUnique
     *
     *  This function will create a new file or directory in the
     *  file system. Any nodes that have not been created or
     *  resolved, will be.  If this file already exists, we try
     *  variations on the leaf name "suggestedName" until we find
     *  one that did not already exist.

So I think it should already do this, but it can fail when there are already many files that were tried and exist already, I have no idea what internal rules are used during the name creation. So I could imagine that if you keep getting an attachment named only "invoice" it may eventually run out of unique file names. The date stamp would definitely be helpful to ensure uniqueness, but it may not be as useful as maybe also using the subject line (of course there may be restrictions because of file name length, and illegal characters such as ? or *)

What would a typical invoice mail look like? (what kind of common properties doe they have, doers the subject always start with a certain word? Is there something that makes the subject unique? Would it maybe make sense to include the current folder or filter name - if you have different filters for different customers this may add some value too.

RealRaven2000 commented 4 years ago

PS: note that nsIFile will eventually not be supported by Thunderbird as it is an XPCOM interface and they won't allow Add-ons to use these anymore. AT this stage I am not sure what it will be replaced with.