Context Menu (ServiceMenu) in KDE4 for "Send as e-mail" 
Quite often I send multiple files via e-mail. My Desktop is driven by KDE4 and I use Icedove (Thunderbird) as Mail-Client. Sadly in KDE4 there is no context menu in the file-manager (dolphin / konqueror) that give the functionality to create archive of multiple files on the fly and send the achive as e-mail.
So I created a KDE4 ServiceMenu file in /usr/share/kde4/services/ServiceMenus/sendwithicedove.desktop
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin,all/allfiles,inode/directory
ExcludeServiceTypes=kdedevice/*
Encoding=UTF-8
Actions=sendwithicedove;sendtargzwithicedove;sendzipwithicedove;
[Desktop Action sendwithicedove]
Exec=icedove -compose
"$( echo -ne "subject=Attachments,body=Files:n
"; for i in $(echo %F); do echo ' '$(basename ${i}); done; echo -n ",attachment='
"; for j in $(echo %F); do echo -n file://${j},; done; echo "'
";)"
Icon=icedove
Name=Send as E-Mail Attachment (Icedove)
Name[de]=Als Anhang per E-Mail senden (Icedove)
[Desktop Action sendtargzwithicedove]
Exec=icedove -compose
"$( echo -en "subject=tar.gz-file: archive.tar.gz,body=Content:n
"; for i in $(echo %F); do echo ' '$(basename ${i}); done; mytmpdir=$(mktemp -d --tmpdir sendtargzwithicedove-XXXXXXXXXXXX); tar czf ${mytmpdir}/archive.tar.gz --transform='s#^.*/##' %F 2> /dev/null; echo -n ',attachment=file://'${mytmpdir}'/archive.tar.gz'; )"
Icon=icedove
Name=Send as tar.gz Attachment E-Mail (Icedove)
Name[de]=Als tar.gz-Anhang per E-Mail senden (Icedove)
[Desktop Action sendzipwithicedove]
Exec=icedove -compose
"$( echo -en "subject=zip-file: archive.zip,body=Content:n
"; for i in $(echo %F); do echo ' '$(basename ${i}); done; mytmpdir=$(mktemp -d --tmpdir sendzipwithicedove-XXXXXXXXXXXX); zip -9qjr ${mytmpdir}/archive.zip %F 2> /dev/null; echo -n ',attachment=file://'${mytmpdir}'/archive.zip'; )"
Icon=icedove
Name=Send as zip Attachment E-Mail (Icedove)
Name[de]=Als zip-Anhang per E-Mail senden (Icedove)
(If you are using Thunderbird, then you must replace icedove with thunderbird manually)
It provides there menuitems the dolphins and konquerors context (right-click) menu:
- Send as E-Mail Attachment (Icedove)
- Send as tar.gz Attachment E-Mail (Icedove)
- Send as zip Attachment E-Mail (Icedove)
The script has some disadvantages:
- It doesn't clean up the /tmp directory: It can't to, becuase the archive must say there until the user really send the e-mail.
- It does store directories recursively, but the file-list in the e-mail body only list the directory and not the files within (Hereby I define this as feature :-))