37signals, 40hz, 2008, 2010, 05401, 05403, 05446, 05462, 05482, 05673, 05701, aardman animations, ac propulsion, adium, ads, aim, airport, al franken, algorithm, amazon, andy hertzfeld, animation, apache, apple, applescript, architecture, archive, art, article id, asterisk, at&t, atom, automobile, away message, backpack, badge, barack obama, basecamp, bash, beos, bernie sanders, bicycling, bill atkinson, billboard, blacklisting, blog, blogroll, blogzot, bluetooth, blunt, bluray, book, bookmarklet, bot-net, brad bird, browser, btv, bug, build, bungie, bunny, burlington, call of duty, camera, camping, can-spam, cars, centralized, channel camp, chocolate, classic, classic mac workshop, clipcat, clothing, cms, collection, color classic, comedy, comedy central, comic, computer, concert, conversion, cookbook, corrosion, cowards way out, crack, crashing, creature comforts, criticism, daring fireball, darwin, dashboard, david byrne, dcl, death, delicious, derbi, design, development, digg, dilemma, discussion, disney, domain, download, drivers, dvd, dynetk, e-mail, e3, easter, ebox, eckhart, eckhart koppen, eckhart köppen, eddie izzard, edward gorey, einstein, eject, election, electric motorcycle, electric motorsport, electric vehicle, electronics research laboratory, elmo, emate, emulator, encryption, environment, environmental impact, erin mckeown, escale, exploit, express 530t, expressionengine, feature, feed, feedburner, filtering, finance, firmware, fixdavsvn, flickr, flynn center, focus, font, food, ford, for sale, free, freeverse, freezing, fresh air, frog design, front row, fusion, games, gears of war, geek, geek technique, geocities, git, github, gmail, google, gpr, grammar, grant hutchinson, graylisting, gtd, hack, haiku, halo, hayao miyazaki, health, higher ground, highrise, hiking, hiroshi noguchi, history, hope, hotspot, html, html5, hulu, humor, hybrid, hybrid technologies, hypercard, intel, internet, interview, ipad, iphone, ipod touch, isao takahata, itunes, jabber, japan, javascript, jetblue, jfk, john gruber, john oliver, jon stewart, kid koala, launchd, layover, leopard, liberal, long trail, lorem ipsum, mac, macbook pro, mac mini, macpaint, mac pro, macworld, maczot, magazine, mail, maine, makkintosshu, marathon, marketing, mark hoekstra, matthias melcher, media, mesagepad, messagepad, microbus, microsoft, mobileme, model s, modern warfare, money, monitoring, moon river, motorola, movie, movies, mrtg, multitasking, music, mwsf07, mystic, nascar, ncx, nda, netflix, network, newt/0, newton, newton os, newton press, newtonscript, newtontalk, newton x press, nick park, nitch, npr, on point, openpbx, open source, operation ivy, optimization, organic, os 6, os 8, os9, osheaga, osx, os x, owc, package, palm, password, patch, paul guyot, pbx, pdf, pesticides, photography, pico card, pilot, pixar, playstation, plist, plug-in, pod jungle, politics, productivity, ps3, psp, pump-and-dump, quickdraw, quicksilver, racism, rack-n-roll, radio, ratatouille, realpath, rebooting, recycling, regex, regular expressions, remake, required reading, restoration, retrochallenge, review, roadster, room without a window, rss, scion, screencast, script, search, security, server, sesame street, seven days, shame, shelburne, shelburne museum, shirt, shoppinging cart, signature, simon bell, small dog electronics, snow leopard, social, software, solution, sony, spam, spam haus, startup item, statistics, status, stefano paris, stephen colbert, steve jobs, steven colbert, steven frank, studio 360, studio ghibli, subethaedit, subversion, susan kare, swiss, swuser, sync, syndication, sysmon, tablet, tags, tax, technorati, ted talk, television, terry gross, tesla motors, textpatter, textpattern, the colbert report, the daily show, the flaming lips, the gashleycrumb tinies, the radiator, the world, times argus, titles, tkip, todd kollins, tom gage, tools-osx, trailer, trash, travel, tree, trends, troubleshooting, truetype, twitter, typography, tzero, unicel, universal access, unna, update, upgrade, url title, user interface, v710, venue, verizon wireless, vermont, victor rehorst, video, virtualization, vmware, volkswagen, volvo 122, vpr, vw, wait wait don't tell me, wall-e, wallace & gromit, wavelan, web, web 2.0, webkit, web site, whitepaper, wifi, wikipedia, windows, winter warm-up, wireless, wpa, writing, wwdc, wwnc, xbox 360, xbox live, xhtml, xserve, yahoo, ze frank, zero emission

Technorati Chart for 'mail'

Articles Tagged "mail":

Mail's Broken Reply/Redirect/Forward AppleScript Support ¬

2007-08-07

I use the excellent spamtrainer tool on Mac OS X Server mail servers so that I and others can more easily spamassassin what’s spam or not. Up until now I’ve been content to do the following to manually redirect the messages to the junkmail account:

  1. Select the first message in my Junk folder
  2. Cmd-Shift-E (redirect)
  3. “junkm”-Tab (to select my junkmail@domain.tld address)
  4. Cmd-Shift-D (deliver)
  5. Down arrow
  6. If that wasn’t the last message then goto step 2
  7. Else, Cmd-A (select all) and delete/backspace

However, even with spamassassin ripping out most of the spam upfront, there can still be a considerable amount of spam to redirect on Monday mornings and I really don’t need RSI from redirecting spam.

Since I had already tackled some additions to a John Gruber AppleScript a couple weeks ago, I figured I could reasonably solve this problem with an AppleScript. So I whipped out Script Editor, the dictionary for Mail, and the example scripts in /Library/Scripts/Mail\ Scripts/ and started to attack the problem. The only issue: I kept getting “ undefined” errors where the redirect command was supposed to be returning an outgoing message.

Naturally, I figured I must be doing something wrong since I’m not an AppleScripter. After a quick search on macosxhints.com I found an AppleScript to batch-redirect email in Mail.app, but I kept getting the same error with it. I hit up Google, Apple’s AppleScript-users mailing list archives, and MacScripter’s forums and dug out some very unfortunate news: there is “a bug in Mail evidently prevents it from returning a reference (as it should) to a new message created using the forward, redirect or reply commands” and it’s been there for a while (since the release of Tiger).

Verifying the Bug

I had pretty much found all the proof I needed to start getting discouraged, but I had to flesh it out and understand it so as not to be more discouraged… or maybe to further discourage myself? Either way, I developed the following script to test the cases:

using terms from application "Mail"
	on perform mail action with messages selectedMsgs
		tell application "Mail"
			set selCount to (count of selectedMsgs)
			repeat with counter from 1 to selCount
				set msg to item counter of selectedMsgs
				-- try to create a new message
				set newMsg to make new outgoing message with properties {subject:"New AppleScript-genereated Message", visible:true}
				-- try to reply to a message
				set newReplyMsg to reply msg with opening window
				tell newReplyMsg
					set subject to "(AppleScript-generated)" & msg's subject
				end tell
				-- try to forward a message
				set newForwardMsg to forward msg with opening window
				tell newForwardMsg
					set subject to "(AppleScript-generated) " & msg's subject
				end tell
				-- try to redirect a message
				set newRedirectMsg to redirect msg with opening window
				tell newRedirectMsg
					set subject to "(AppleScript-generated) " & msg's subject
				end tell
			end repeat
		end tell
	end perform mail action with messages
end using terms from
-- this is required when _not_ running from the Script menu (e.g. Script Editor, FastScripts, etc.)
using terms from application "Mail"
	on run
		tell application "Mail" to set sel to selection
		tell me to perform mail action with messages (sel)
	end run
end using terms from

If you select one or more messages in Mail and run that script (you can shuffle around the order of creating the reply, forward, or redirect messages if you like) you’ll see the following:

  1. A new, blank message window with the subject “New AppleScript-genereated Message”
  2. A reply to the first message selected
  3. The following error in Script Editor: “The variable newReplyMsg is not defined.”

In Script Editor’s Event Log you’ll see the following:

tell application "Mail"
	get selection
		{message id 768388 of mailbox "Junk" of account "Morgan"}
	make new outgoing message with properties {subject:"New AppleScript-genereated Message", visible:true}
		outgoing message id 248907776
	reply message id 768388 of mailbox "Junk" of account "Morgan" with opening window
		"The variable newReplyMsg is not defined."

The interesting bit is that outgoing message id 248907776 was returned for the call to make new outgoing message with properties, so at least that works correctly.

I wrote the following script to attempt to peek at the id of each outgoing message in the hopes that I might just be able to set the response from redirect/reply/forward manually:

using terms from application "Mail"
	on run
		tell application "Mail"
			repeat with counter from 1 to (count of outgoing messages)
				display dialog "Outgoing message #" & counter & "'s ID #: " & id of item counter of outgoing messages
			end repeat
		end tell
	end run
end using terms from

Apparently Mail considers a message viewer window to be an outgoing message because this script will show the id of the selected message in an open message viewer window. Also, If you leave the new message created with the first script (i.e. the one created by the call to make new outgoing message with properties) open it’ll show the id of that message. However, if you use either a script or manually reply/forward/or redirect a message you’ll get the following error in Script Editor: “Mail got an error: NSReceiverEvaluationScriptError: 3”.

It’s starting to really get interesting, huh!

H3. The Hypothesis

By this point I’ve pretty well confirmed that not only do the reply, forward, and redirect commands not return an outgoing message as they’re supposed to, it appears that they don’t even have ids set. We also know that scripts that relied on these commands worked prior to Mac OS X 10.4 (Tiger).

So what changed in Tiger that might play a part in causing this bug? Well, Apple switched mail from storing all messages for a folder in .mbox format to storing each individual message in their own .emlx file so that Spotlight could more efficiently/easily index those messages.

Is Mail may not generating an id for the new messages because it hasn’t saved them to disk yet? I believe so. And in the case of calling make new outgoing message with properties directly, you’re generating the object right then and there so it gets an id.

Workarounds?

To get around this I can just create a new message and fill in all the requisite properties, right? Almost.

Unfortunately, an outgoing message object contains only a subset of the properties that a message object contains. Most importantly, you have no way to pass the headers from the original message into a new outgoing message which is vital in the case of redirecting messages for training spamassassin as it inspects the full headers. Also, you lose Mail’s tracking of what messages were replied to, forwarded, or redirected, and linking them together (a handy feature to have to give up).

In some cases one can simply make a Rule in Mail to reply, forward, or redirect, but that won’t work in my case. It looks like I’ll have to do this using GUI scripting and have to watch all the messages pop up, fill in, and then disappear.

I do hope this at least helps bring this issue out into the spotlight a little more since it’s existed for so long. I also hope to save someone a lot of wasted effort.

Non-Top-Posting Reply Scripts for Apple Mail (with Signature Support) ¬

2007-07-11

Today John Gruber posted an excellent set1 of AppleScripts that automate replying without top-posting in Apple’s Mail.app. You can read his article for the full description.

It’s exactly what I’ve been looking for to allow myself to keep my anal-retentive e-mail replying habits and increase productivity. However, I had one problem with his implementation: it doesn’t handle signatures gracefully.

I have a couple different e-mail accounts in Mail.app that I use on a daily basis and each has a unique signature (which also helps me know which account I’m replying from), but his script dumps you after the signature if you have one set to be auto-selected. I could just set it to select “None” by default, but then I lose the increased efficiency by having to select the signature.

So, I came up with a four-line addition to his script which adds the following fourth step to his process:

  • If no default or random signature is selected, select the first signature from the pop-up menu.

It is implemented by adding the following immediately before the second-to-last “end tell“:

if value of (pop up button 1 of window 1) is "None" then
	click pop up button 1 of window 1 -- The "Signature" Pop-up
	click menu item 3 of menu 1 of pop up button 1 of window 1 -- The first signature in the list
end if

Of course, one can always change “menu item 3“ to read “menu item ‘signature-name“, where “signature-name“ is the name of the signature you want to select, if you don’t want it to just pick the first out of the list. Hell, you can even modify it to pick a random signature if you want.

So, to be as clear as possible, the full, modifed, AppleScript is as follows:

tell application "Mail" to activate
tell application "System Events"
	tell process "Mail"
		tell menu bar 1
			click menu bar item "Message"'s menu "Message"'s menu item "Reply"
		end tell
		delay 0.5
		key code 117 -- Forward Delete
		key code 125 using command down -- Down Arrow
		key code 36 -- Return
		if value of (pop up button 1 of window 1) is "None" then
			click pop up button 1 of window 1 -- The "Signature" Pop-up
			click menu item 3 of menu 1 of pop up button 1 of window 1 -- The first signature in the list
		end if
	end tell
end tell

Thanks go out to John. Hopefully my modifications will be helpful to others too.

Update: My apologies for the horrendously tiny font for my code blocks. I’ve had a redesign in the works for a while. The site redesign has now gone live, so the code font should be much more legible.

1 I guess you’d call it a set. It’s one script with instructions for the one word addition to make the second script.

Regarding 'Mail Pro' ¬

2007-07-05

There has been an an ongoing discussion regarding a better e-mail application for Mac OS X.

I have to agree with Brent Simmons on the specific needs to make e-mail friendlier to Pro users (emphasis mine):


1. No clicking to file a message. Keyboard only.

2. No clicking—or tabbing plus arrow arrow arrow arrow arrow arrow arrow arrow arrow—to go to a mailbox.

3. Easy searching multiple mailboxes.

4. IMAP.

5. Editor with macros (think BBEdit’s clippings, TextMate’s snippets, vim’s abbreviations).

6. Mac-app-ness.

Mail doesn’t do 1, 2, and 5.

I have to deal with a lot of mail and I don’t always deal with it appropriately because it’s not easy enough to get through. I’m now great at training my mail server’s junk mail filters via various keyboard twitches that I’ve mastered, but the rest of the e-mail client should function just as well.

I’ve been using Adam Tow’s excellent MsgFiler plug-in for Mail.app and it’s helped me greatly with the filing of e-mail messages and with the opening of most1 folders in Mail.app. However, this functionality should be built-in as well.

In terms of the no market for a non-free ‘Pro’ e-mail client for Mac OS X, I definitely have to side with Michael McCracken that there is definitely for a market for a paid, Pro e-mail application:

How is the market for programmer’s editors? XCode is free and very good, emacs, vim, etc. are also free and excellent. But there are people making money selling text editors. People buy BBEdit, TextMate, and SubEthaEdit because these programs have important features that give you more power over something that they do all day.

I bought SubEthaEdit. Hell, as I mentioned above, I bought MsgFiler, a Mail plug-in that adds functionality that I feel should be built-in!

Paul Kafasis also noted: “What’s to stop an open source client? I’d say very little, except for the incredible effort needed. “ And went on to say the following:

I think a nice solution here, and perhaps in general, would be a MailKit framework, similar to WebKit. Mail could be built on top of it, and be free, and developers could build custom clients as well.

The thing is, Matt Ronge has been working on MailCore (i.e. Paul’s ‘MailKit’) and Kiwi (the e-mail client) for quite some time now. It’s far from done, but we’re well on our way.

Now, Paul is entirely correct that it’s a lot of work. Interestingly, Matt’s original reason for writing MailCore and Kiwi is because Mail.app (and it’s not alone here) is horrendous at handling IMAP appropriately.

If Kiwi is released with excellent support of the IMAP protocol2 and can check-off everything on Brent’s list then I’d totally dish out some cash for it. In fact, I think many people would. If someone else beats him to the punch? I would plunk down my credit card for the best option for me.

Just because Apple includes a free Mail application in Mac OS X that’s about as good (give or take a feature here and there) as most other free e-mail clients, doesn’t mean that there’s no market for a paid, ‘Pro’ e-mail client.

Update: Matt Ronge has posted regarding the state of e-mail in which he discusses his improved motivation for developing MailCore/Kiwi and the fact that he had considered making Kiwi a commercial app.

1 It currently doesn’t allow you to search for and file messages to or open one’s various inboxes, so that has to be done manually.

2 If it also supported IMAP’s IDLE command, I’d be even happier.