Go Back   The macosxhints Forums > OS X Help Requests > Applications



Reply
 
Thread Tools Rate Thread Display Modes
Old 08-15-2012, 03:04 PM   #1
joestalin
Triple-A Player
 
Join Date: Jun 2002
Posts: 56
Some actions for mail rules not active under 10.8

I use a lot of rules in Mail to funnel messages into various mailboxes. For a few of these, I also want to play a sound or run a script.

What I have found since upgrading to Mountain Lion is that messages are still getting funneled into their mailboxes correctly--so I know the rules are still active and working--but the sounds and scripts associated with those rules are not activating.

The only possible complication that comes to mind is that I run Dockstar. It's never caused a problem before, but I can imagine it might interfere with rules.

Has anyone experienced this or solved it?
joestalin is offline   Reply With Quote
Old 08-15-2012, 04:26 PM   #2
ganbustein
MVP
 
Join Date: Apr 2008
Location: Berkeley CA USA
Posts: 1,010
When I was converting from Eudora (on MacOS 8.6) to Mail (on OS X 10.5), I simply could not get sounds to play reliably. I finally gave up on having Mail play sounds, instead having AppleScripts (which I was already using for routing) include a line like, for example:
do shell script "/usr/bin/afplay /System/Library/Sounds/Submarine.aiff"
A new problem I'm running into with MtLion is that Mail will invoke your rules before it has all the headers for new messages. That is, get all headers of aMessage doesn't get all the headers. Well, actually, Lion had the same problem, but I could get around it by using get source of aMessage, and parsing the headers out of that:
Code:
on getDeliveryHeaders(theMessage)
	
	tell application "Mail" to set messageSource to source of theMessage
	set temp to offset of character id {10, 10} in messageSource
	set rawHeaders to text 1 thru (temp - 1) of messageSource
	
	-- replace tab with space (simplifying LWSP detection)
	set text item delimiters to tab
	set headerItems to text items of rawHeaders
	set text item delimiters to " "
	set rawHeaders to headerItems as text
	
	-- unfold header lines by replacing LF SP with SP
	set text item delimiters to character id {10, 32}
	set headerItems to text items of rawHeaders
	set text item delimiters to " "
	set rawHeaders to headerItems as text
	
	set fullHeaders to paragraphs of rawHeaders
	repeat with aHeader in fullHeaders
		set aHeader to contents of aHeader
		try -- parsing a malformed header may throw an error; ignore such headers
			set temp to offset of ":" in aHeader
			set headerName to text 1 thru (temp - 1) of aHeader
			repeat while headerName ends with " " -- ignore whitespace before ":"
				set headerName to text 1 thru -2 of headerName
			end repeat
			set headerBody to text (temp + 1) thru -1 of aHeader
			if headerName is ...

			else if headerName is ...

			end if
		end try
	end repeat
	return ...
end getDeliveryHeaders
That worked fine through 10.7.4, but as of 10.8, Mail won't even give you the full source. It apparently gives you what it has, but that might not even be all the headers.

This makes no sense to me. How can Mail expect your filters to reliably sort the message when even Mail itself hasn't yet seen all the headers? But, that's what it's doing.

I can detect this by noticing when offset of character id {10,10} of aMessage is 0, and when it happens delay a fraction of a second and ask for the source again. That gives me more of the source, and I can loop until I've at least got all the headers, but if I delay too long Mail decides my script has hung, and things get wonky. (Sorry I can't be more specific about what goes wrong after that, but this is really hard to debug.)

I'm working on a workaround where I simple flag the message as needing to be re-considered, and firing off an asynchronous shell script that will do the re-considering a few seconds later. That should satisfy Mail that my filter is responsive, but again debugging/testing is slow, since I have no way to fabricate test data.

Not knowing your scripts, I can't say whether your problem and mine are related, but I can confirm that MtLion's Mail does have new issues with regard to scripts invoked from mail rules.
ganbustein is offline   Reply With Quote
Reply

Tags
mail, mountain lion, rule, rules, sound

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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



All times are GMT -5. The time now is 01:38 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.