• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Mail Rule Finder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail Rule Finder


  • Subject: Re: Mail Rule Finder
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 12 Oct 2011 22:16:08 -0500

On Oct 12, 2011, at 19:51, Gil Dawson wrote:
When someone changes his relationship with me (moves from Friend 6 to Board Member, for example) it's been tedious to find which condition in which rule contains his email address so that I can delete it and add it as a new condition to another rule.  Until now.

I just wrote this and it seems to work nicely:
______________________________________________________________________

Hey Gil,

I haven't scripted Mail's Rules, but this is interesting - so I'll have a go.

As long as you have the complete email address you can do something like this:

tell application "Mail"

name of rules where its rule condition's _expression_ contains "email@hidden"

end tell


So to extrapolate:

try  
  set theClue to "applescript-users.lists.apple.com"

  

  tell application "Mail"
    set filterName to item 1 of (get name of rules where its rule condition's _expression_ contains theClue)
    set ruleNames to name of rules
    repeat with ruleNameIndex from 1 to length of ruleNames
      if item ruleNameIndex of ruleNames = filterName then exit repeat
    end repeat
    set ruleExpression to rule filterName's rule condition's _expression_
    repeat with expressionIndex from 1 to length of ruleExpression
      if item expressionIndex of ruleExpression = filterName then exit repeat
    end repeat
  end tell

  

  {filterName, ruleNameIndex, expressionIndex}

  

on error errMsg number errNum
  set {cr, sep} to {return, "------------------------------------------"}
  set e to sep & cr & "Error: " & errMsg & cr & sep & cr & "Error Number: " & errNum & cr & sep
  beep
  display dialog e
end try

This runs in about 1/100 of a second on my machine from Script Debugger.

If I were maintaining large lists of rules I'd be tempted to try to script the add/remove condition step, or I might at least try writing a UI script to display the affected rule.

I might also be tempted to try writing my own filter script using text lists and the Satimage.osax's 'find text' with regexp capability.  If I didn't already use Mail Act-On I would have done something like this already - at least as a manual filter.

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Run As Root (From: Luther Fuller <email@hidden>)
 >Re: Run As Root (From: Stan Cleveland <email@hidden>)
 >Re: Run As Root (From: Luther Fuller <email@hidden>)
 >Mail Rule Finder (From: Gil Dawson <email@hidden>)

  • Prev by Date: Mail Rule Finder
  • Next by Date: Re: INDESIGN: Coercing a String to a Constant
  • Previous by thread: Mail Rule Finder
  • Next by thread: Re: Mail Rule Finder
  • Index(es):
    • Date
    • Thread