I often compose emails in TextMate and paste them into new messages in Mail. I think there should be a automated way of doing this.
What I've come up with so far involves transforming the document into a link and runing it with the "open" command. Something like this:
open "mailto:jo@foo.net,%20elizabeth@bar.com? cc=sam@fake.org&subject=New%20Fall%20Schedule&body=Hey%20guys%21%0A% 0AI%20just%20wanted%20to%20let%20you%20know%20that%20I%20was%20in% 20town%20next%20tuesday.%20Please%20call%20me%20at%20818-555-1234%20so %20we%20can%20set%20something%20up.%0A%0ASee%20you%20then%21%0A%0A-- oliver"
This works reasonably well.
Obviously, transforming the document into a single link would require:
1. A syntax 2. URL escaping 2. Some clever search/replace
But before I invest time into this I wanted to ask you guys what you thought.
Is this a good candidate for the existing mail bundle? Are there better ways of sending the message to mail than thru a link? What are your thoughts?
--oliver
Sounds like a good candidate for AppleScript... I'll check my code repository, as I'm pretty sure I have a snippet that creates a new Mail message and populates it with data...
BRB...
-- Ale Muñoz http://sofanaranja.com http://appleweblog.com
My thoughts exactly. Mail has a great Applescript dictionary and Textmate can parse the text and populate all the variables necessary.
On Nov 6, 2006, at 2:39 PM, Ale Muñoz wrote:
Sounds like a good candidate for AppleScript... I'll check my code repository, as I'm pretty sure I have a snippet that creates a new Mail message and populates it with data...
BRB...
-- Ale Muñoz http://sofanaranja.com http://appleweblog.com
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Here's the AppleScript code to create a new email:
set theSubject to your_subject_variable_here set theContent to your_content_here tell application "Mail" activate set newMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true} end tell
Caveats:
I've never tested it with multiline content (it was part of a script that automatically created the content)
If you have any problems with new lines, the way to insert a linebreak in AppleScript is:
set multiline to "foo" & return & "bar" & "baz"
Play a little bit with this ('man osascript' for info on how to call AppleScript from the command line) and tell me how it works. It looks like a nice addition to the TextMate arsenal :)
Hope it helps
-- Ale Muñoz http://sofanaranja.com http://appleweblog.com
Just a thought, but if TM saved the file before running the command, applescript could just read the file off the disk and preserve the formatting perfectly in the message:
set a to "/Users/Brett/Desktop/test.txt" set theFile to POSIX file a open for access theFile set theBody to (readtheFile) close access theFile tell application "Mail" set new_mess to make new outgoing message with properties {content:theBody, visible:true} activate end tell
On Nov 6, 2006, at 2:45 PM, Ale Muñoz wrote:
Here's the AppleScript code to create a new email:
[...]
On 6. Nov 2006, at 21:34, Oliver Taylor wrote:
[...] What I've come up with so far involves transforming the document into a link and runing it with the "open" command [...]
Obviously, transforming the document into a single link would require:
- A syntax
- URL escaping
- Some clever search/replace
But before I invest time into this I wanted to ask you guys what you thought.
I think it sounds like a great idea -- and it has the property that it works with the users default mailer, not just Mail (as AppleScript would).
I did a simple proof-of-concept, it expects headers at the top in the normal mail-style, i.e. keyword + colon + field value.
I gave it ⇧⌘D as key equivalent and scoped it to text.mail.
I think this should be added to the standard mail bundle.
Man, that works really well. Nice job, guys.
Brett
On Nov 6, 2006, at 7:46 PM, Allan Odgaard wrote:
On 6. Nov 2006, at 21:34, Oliver Taylor wrote:
[...] What I've come up with so far involves transforming the document into a link and runing it with the "open" command [...]
Obviously, transforming the document into a single link would require:
- A syntax
- URL escaping
- Some clever search/replace
But before I invest time into this I wanted to ask you guys what you thought.
I think it sounds like a great idea -- and it has the property that it works with the users default mailer, not just Mail (as AppleScript would).
I did a simple proof-of-concept, it expects headers at the top in the normal mail-style, i.e. keyword + colon + field value.
I gave it ⇧⌘D as key equivalent and scoped it to text.mail.
I think this should be added to the standard mail bundle.
<Send Letter to Mail.tmCommand>
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brett Terpstra : Art Director Circle Six Design, Inc. 111 Riverfront Dr, Suite 204 .................................................. p: 507.459.4398 877.858.4332 f: 1.866.540.3063 e: brett@circlesixdesign.com http://www.circlesixdesign.com ..................................................