Friday, June 8, 2007

Attach files to thunderbird directly from commandline

Install the script ( e.g attach.sh )


#! /bin/bash
#
# Script created by ASID
# Modified by sura
# Attach files to thunderbird

temp=""
count=0
mydir=`pwd`
for i in $*
do
count=$(( $count + 1 ))
if [ $count -eq $# ]
then
temp=${temp}file://${mydir}/${i}
else
temp=${temp}file://${mydir}/${i},
fi
done

echo $temp

if thunderbird -remote "ping()" 2> /dev/null ;
then
thunderbird -remote "xfeDoCommand(composeMessage,attachment='$temp')"
else
thunderbird --compose "attachment='$temp'"
fi





Then just issue the command

bash attachs.sh filenames