Create plugin for thunderbird to save attachments into a folder automatically created


(Nikzodiac2) #1

Hi, I wonder if is possible to create a thunderbird plugin that can extract all attachments into a folder automatically created and named with the subject of the email.

everytime I save many attachments from an email with subject “order xxx” I have to create a folder in the desktop named “order xxx” and save all into it… If i forgot to create a folder doing only “save all” I’ll find hundreds of attachments in my desktop

this plugin would be helpful and I hope not so hard to create (not for me of course)

please let me know if is possible to make it
thanks for the attention
bye


(Martin Giger) #2

Hey, moved this over to the Thunderbird discourse category, where it’s a lot more likely to be answered.


(Nikzodiac2) #3

is happened once at least that an user ask to create a plugin and someone done it??


(Nikzodiac2) #4

sounds like there is no hope :frowning:


(Ryan Sipes) #5

It has only been a day @blanka - I’m sure it is possible to make this, have you already searched through the add-ons to see if there is anything that accomplishes this?

https://addons.mozilla.org/en-US/thunderbird/search/?q=attachment&appver=&platform=

That is a list of add-ons found doing a search for “attachments”.

If you want to take a stab at creating an extension, there is a tutorial here:

That should get you started, once you learn the basics, you can talk to us via #thunderbird or #maildev on IRC (Moznet).


(Nikzodiac2) #6

Yes, I’ve already tried all plugins but none can do it…
create a plugin requires a technical knowledge that I haven’t…


(Julien Tane) #7

do you want it to be automatic when a name satisfying a given filter comes in?


(Nikzodiac2) #8

when I have many attachments into an email, before to save them I have to create a folder named with the subject of the email (for exemple “order 1”)…
I would like that when I save the attachments the folder is automatically created and named with the subject of the email (“order 1” in this case)


(Julien Tane) #9

FYI I started to look into it as a way to familiarize myself with the thunderbird code.

I am new to thunderbird development but maybe I will manage to do something.

For developpers, I see two different ways of solving this:

  • try to do this with an addon
  • adding a save attachment function to filters

I am not sure this is the right place to continue discussing about this though.


(Vseerror) #10

I know this has been discussed inthe context of the filtaquilla addon - which IMO has the most potential for making this possible. See https://support.mozilla.org/en-US/questions/1008329


(xerostomus) #11

Dear Sirs,
I am also desperate because of this. I urgently needed to extract a few hundreds of emails with attachments, so I wrote a macro for me. I know it is stupid and dangerous, but it worked somehow and I have all my attachments extracted yet. I paste the bash script here, use it if you want, but be very careful. It only sends keys to the Thunderbird menu and it does actions without any feedback.

#!/bin/bash
#install xdotool
#sudo apt install xdotool
#Read carefully this script to understand it fully
#set your variables, namely $directory_attachments and shortcuts of xdotool
#I have German menu in Thunderbird so all keyboard shortcuts are different if you are in English Thunderbird or say Greek one. Then you have to modify the commands of xdootool.
#Take care, this script moves all your attachments into a temporary directory ~/$directory_today, where you can find them.
#When it runs, monitor, what it is doing - it is a stupid keyboard makro, it only sends keys to Thunderbird, it is no mistake prove program.
#Test it first with long delays, to see what is doing in your special enviroment.

window_script=$(xdotool getactivewindow) # it gets the PID number of this script
echo “Open Thunderbird”
echo “Sort emails according to attachment”
echo “Select the first email with an attachment to convert.”
echo “Now we should find the number of the window of Thunderbird.”
echo “Arrange windows on your desktop to see both - this script window and the window of Thunderbird.”
read -p “Press Enter and THEN activate window of Thunderbird and click on its title bar”
window_thunderbird=$(xdotool selectwindow )
echo $window_thunderbird > /tmp/thunderbird_pid.tmp
echo The Thunderbird has a PID number: $window_thunderbird

directory_attachments=~/directory_where_Thunderbird_stores_your_attachments_by_default
delay1=0.5s
delay2=1s # small attachments
delay2=1.5s # big attachments
delay3=1.5s # small attachments
delay3=3s # big attachments
number_emails=10 # 10 if you want to control only 10 email in a row
number_emails=1 # 1 if you want to extract only one email per time, say problems or big attchments

xdotool windowactivate $window_thunderbird
directory_today=ready$(date +%Y-%m-%d )
mkdir ~/$directory_today
i=1; # reset counter
while [ 1 ] # do for ever and ever
do
mv -v --backup=numbered $directory_attachments/* ~/$directory_today
#moves all attachments from default direcotry into new directory, not to be overwriten by Thunderbird
xdotool windowactivate $window_thunderbird
sleep $delay1
xdotool key alt+N # open menu Nachricht. Probably Messages in English menu
echo alt+N delay1
sleep $delay1
xdotool key h # open menu Anhängen - probably Attachement in English menu
echo h delay1
sleep $delay1
xdotool key a # open menu Alle abtrennen. Probably Extract All in English menu
echo a delay1
sleep $delay1 # name of file dialog
xdotool key Return
echo Return first delay2
sleep $delay2 # save of file dialog
xdotool key Return
echo Return second delay3
sleep $delay3 # saving

i=$(( $i + 1 )) # increase the counter
if [ $i -gt $number_emails ]; then
xdotool windowactivate $window_script
read -p “Press Enter to continue (Ctrl-C to break)”
i=1 # reset counter
fi
done
exit