Reply
Page 1 of 2:  1  2   Next >
Thread Tools Search this Thread   Switch to Linear ModeSwitch to Hybrid ModeSwitch to Threaded Mode
grotsasha
grotsasha's Avatar
Cocoatech

Join Date: Dec 2005
Location: Düsseldorf, Germany
Posts: 1,739
Email / Compress and Email script for Thunderbird, Posted Feb 18, 2006, 07:19 AM #1
The Thunderbird script works only with latest nightly builds (won't work on 1.5 due to a bug in Thunderbird). Current Thunderbird version (2.0 ) has a bug that makes PF hang and wait till you send the mail and quit Thunderbird, which is very inconvinient.


--------------------------------------------------------------

I also began to play a bit with Thunderbird. It's not scriptable, but it accepts command line arguments, so I started with the idea to do it with a "do shell script" applescript command. But it didn't want to work. Getting out of my nerves because everything seemed to be correct, I finally found the reason: unfortunately Thunderbird 1.5 has a bug that prevents making attachments from the command line. :twisted:

Quote:
The -compose command line argument doesn't work correctly in Thunderbird 1.5 due to a parsing bug. It generates the compose message window but none of the fields are filled in. The only workaround is to use a mailto: URL. However, this prevents you from passing an attachment due to a security restriction.
Need to wait until version 2.0 until they fix it. I use Thunderbird, because it's the only mail client that supports all standard russian encodings and handles them correctly, the option to force it to compose in UTF-8 is also important to me, as I have a strange style of writing messages in a mix of russian, french and german sometimes. So Apple Mail for example gets confused and send them as Chinese or something like that

eMac G4 1,25 GHz 768 Mb
Black MacBook 2,16 GHz 2 GB RAM
10.5
Last edited by grotsasha; Aug 29, 2008 at 04:50 AM. Reason: Brought infos up to date
Reply With Quote
grotsasha
grotsasha's Avatar
Cocoatech

Join Date: Dec 2005
Location: Düsseldorf, Germany
Posts: 1,739
Posted Feb 19, 2006, 05:33 AM #2
I just discovered that they fixed this Thunderbird bug a week ago in their recent nightly build (1.6alpha2). So I just downloaded it and made a very quick and dirty AppleScript (i.e. without any tests, doesn't contain subject, etc, no errors output, etc.) that already works with this nightly build with PF on my machine. I'll elaborate it of course.

Thunderbird command line syntax for attachments is the following:
Code:
/<path>/thunderbird-bin -compose "attachment='file:///path/myfile.jpg'"
Further information on Thunderbird command line syntax can be found on this page

And here's my "3-minutes-effort-sorry" script:

Code:
on send_mail(email_subject, email_message, email_sender, email_recipient, email_files)
	
	set thunderbird_bin to "/Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin -compose "
	
	--Thunderbird needs an URL path
	set email_files to "attachment='file://" & email_files & "'"
	
	do shell script thunderbird_bin & quoted form of email_files
end send_mail
It probably contains as many potential bugs as the quantity of characters in the code, but it works for me

One of known issues with this script is: if Thunderbird is already running it will not work (it launches a second copy and fails) So it should be fixed. Unfortunately the built-in mozilla x-remote-client, which can attach to an existing thunderbird process doesn't work in OS X. This script can't attach more than one file yet, but this is a bit tricky to correct as I get only a global email_files variable, and thunderbird needs to have these multiple files separated with commas...


__________________________________________________ __________________

Here followed a long discussion with flip who helped me a lot to debug my script for Thunderbird mail client. If you want to read about my painful process of getting used to this strange language that is AppleScript, I've moved this thread to Anything Goes.

eMac G4 1,25 GHz 768 Mb
Black MacBook 2,16 GHz 2 GB RAM
10.5
Reply With Quote
neilio
neilio's Avatar
admin


Join Date: Nov 2003
Posts: 1,138
Posted Feb 19, 2006, 10:23 AM #3
I've tweaked the name of this thread to be more descriptive and stickied it so that others can take advantage of this great scripts before we integrate them into Path Finder.

Thanks for sharing, guys!
Slumming at the BeatnikPad
The person you love is 72.8% water
Reply With Quote
grotsasha
grotsasha's Avatar
Cocoatech

Join Date: Dec 2005
Location: Düsseldorf, Germany
Posts: 1,739
Posted Feb 20, 2006, 02:15 PM #4
Ta, ta!!!! It works!!!!!!!!!!

I just made it crash myself with my "display dialog" debugging, but that helped me a lot to figure out a very fine bug!! I'm proud of myself 8) 8)

Ok: Attention, please! Here's a final public alpha (:lol: ) release of the script for Thunderbird mail client, made in close collaboration with flip (need to know your real name, for such serious things! )

README:

Works only with the latest Thunderbird nightly build (1.6a1 built after 15th of February)
Known issues:
- will fail if Thunderbird is already running (launches a second copy and fails). This is very difficult to fix (if at all possible)
- while attaching multiple files for the email command, will not include the first one (in alphabetical order). It doesn't concern the email&compress command (all files are correctly included and compressed in one archive). This should be fixed inside PF (not my fault :roll: ) This issue is the same for all email clients actually
- will maybe have problems if you have some difficult non-ASCII names or strange path to your files

HOWTO:

Until it will be included in one or other form in PF installation, you should copy and paste the text below into the AppleScript Editor, save it as mail_send_message.scpt and replace the original script of the same name (make a backup first just in case) inside the Path Finder.app/Contents/Frameworks/CocoatechAppleScript.framework/Versions/A/Resources/Scripts

The software is provided as is, without any warranty and blah, blah...You can modify it as you like (Am I looking professional? 8) :lol:

Ok, enjoy:

Code:
on send_mail(email_subject, email_message, email_sender, email_recipient, email_files)
	try
		set thunderbird_bin to "/Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin -compose "
		set email_subject to "subject=" & email_subject
		set email_recipient to "to=" & email_recipient
		set email_message to "body=" & email_message
		set attachments to "attachment='"
		
		
		repeat with a_file in email_files
			if a_file as string is (last item of email_files) then
				set attachments to attachments & "file://" & a_file
			else
				set attachments to attachments & "file://" & a_file & ","
			end if
		end repeat
		
		set arguments to email_subject & "," & email_recipient & "," & email_message & "," & attachments & "'"
		
		do shell script thunderbird_bin & quoted form of arguments
		
	on error error_message number error_number
		log error_message & " " & error_number
	end try
	
end send_mail

eMac G4 1,25 GHz 768 Mb
Black MacBook 2,16 GHz 2 GB RAM
10.5
Reply With Quote
flip
Member

Join Date: Feb 2006
Location: Montpellier, France
Posts: 226
Posted Feb 20, 2006, 02:32 PM #5
Quote:
Originally Posted by grotsasha
Ta, ta!!!! It works!!!!!!!!!!

I just made it crash myself with my "display dialog" debugging, but that helped me a lot to figure out a very fine bug!! I'm proud of myself 8) 8)
Congrats!

Quote:
(need to know your real name, for such serious things! )
The name is Philippe Martin. You can call me Philippe, or Flip, if you're feeling lazy. But I claim no credit for the script, you did it!
Reply With Quote
grotsasha
grotsasha's Avatar
Cocoatech

Join Date: Dec 2005
Location: Düsseldorf, Germany
Posts: 1,739
Posted Feb 20, 2006, 03:25 PM #6
Thanks a lot, Philippe!

As the last thing I just checked how it will behave with *really* silly paths and file names. And yes, it get problems. There is no way it will work if the name of your folder contains a mix of all languages and plenty of spaces... But normally one doesn't do such things If several files have difficult names, but are inside a "normal" folder/path then PF get care of them if you choose a compress option, give all this nonsense a name "Archive" and it works. If you don't use compress it fails.
So, ideally, one need the URL encode applescript command inside PF.

eMac G4 1,25 GHz 768 Mb
Black MacBook 2,16 GHz 2 GB RAM
10.5
Reply With Quote
r00st3r
r00st3r's Avatar
Member

Join Date: May 2007
Location: Canada
Posts: 3
Posted May 27, 2007, 01:14 PM #7
I'm curious to know if this script works with TB 2? In addition, can this script be easily modified to work in iPhoto? Our local Mac User Group has some TB users (and I have many clients that are Mozilla/TB users) that would really like to be able to send images from iPhoto through TB. It looks very promising as is though!

Thanks in advance!

(Off to compare your script with the ones for eudora/mail/entourage/aol in iPhoto)
Last edited by r00st3r; May 27, 2007 at 01:42 PM. Reason: update
Reply With Quote
grotsasha
grotsasha's Avatar
Cocoatech

Join Date: Dec 2005
Location: Düsseldorf, Germany
Posts: 1,739
Posted May 28, 2007, 01:04 AM #8
Well, this script as it is written above will not work because internal structure of how Path Finder handles scripts for different email clients has changed since. I remember that when Thunderbird was out I played with it to rewrite it, but I've got into one problem - if Thunderbird is already launched, the script will launch a second copy of Thunderbird and fail. This is a Thunderbird problem, not Path Finder's. I should take time and rewrite and test it to integrate it to PF, I'll try to do it when I have time. Thunderbird is a little bit painful to workaround in AppleScript since it doesn't support it, I'm just building a string of command line arguments and I remember that debugging it was kind of painful. But I'll take a look.

eMac G4 1,25 GHz 768 Mb
Black MacBook 2,16 GHz 2 GB RAM
10.5
Reply With Quote
r00st3r
r00st3r's Avatar
Member

Join Date: May 2007
Location: Canada
Posts: 3
Posted May 28, 2007, 12:35 PM #9
I decided to test it out while I awaited your reply and so far it works, mostly.
I quit TB (v 2.0) and then I setup iPhoto properly (custom icon & the AppleScript file). Next I selected a single image and clicked the email button. All went as it should until it came to the compose window. It had user@host in the body above my signature (correct placement, incorrect value), it had the file attachment name in the to field and the attachment window showed the internal HD icon. So far, the issue I am looking at is figuring out how to place the attachment in the attachment pane. Next I will address the default subject (i forget now if it was correct or not) and then I will test multiple attachments.

I do say though, your base script works at about 80% currently.
primary - 500MHz "Pismo" 640MB 120GB 10.4.9
secondary - dual 450MHz "gigabit" G4 768MB 180GB 10.4.9
Reply With Quote
periferral
Member

Join Date: Jun 2007
Posts: 1
Posted Jun 26, 2007, 07:17 PM #10
i tried this with TB2. Using PF .. i right clicked on a pdf and chose email.

It opened TB with the attachment in a compose window.

However, the PF is now hung. I have to quit Thunderbird to release whatever is locked up and then PF is usable again.

Also r00st3r, how did you get this working with iphoto. When i open iphoto, it still opens mail.app
Reply With Quote
Reply « Previous Thread - Tips and Tricks - Next Thread »
Page 1 of 2:  1  2   Next >
Thread Tools Display Modes Search this Thread
Linear Mode Linear Mode

Advanced Search
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All times are GMT -7. The time now is 04:47 AM.