• 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
oddities with a Mail rule & Numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

oddities with a Mail rule & Numbers


  • Subject: oddities with a Mail rule & Numbers
  • From: 2551phil <email@hidden>
  • Date: Sat, 3 Jun 2017 13:20:25 +0700

I have a mail rule which works on the whole just fine, but there’s a couple of niggles. 

The first one is a curiosity, but one I’d like to understand. 

For some reason, whenever I edit, recompile and save the rule, the first run results in nothing happening. The second and subsequent runs work as expected (save for niggle 2, below).

Nothing changes between the first run and the second. The script isn’t edited or even open. It’s as if the AppleScript component needs to “see it” once before acting on it. The problem does not recur after a login or restart. It only recurs if I edit the script again. 

Anybody have any idea why that might happen?

The second niggle, which I think is down to some error in my scripting, is that the rule often fires on a previous message rather than the latest one in the door. Should I be explicitly deslect the message after I’m done with it?

Here’s a pared down copy of the script. I don’t think the Numbers handler is relevant, but I’ve included it just in case.

TIA


Phil


set targetWord to "whatever"
tell application "System Events"
set theUserPath to (home folder's path as text)
end tell
set the theSpreadsheet to "Documents:myNumbers.numbers"
set theSpreadsheet to theUserPath & theSpreadsheet

using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
repeat with i from (count of theMessages) to 1 by -1
set this_item to item i of theMessages
tell application "Mail"
set mb to name of mailbox of this_item
if mb = "INBOX" then
set theTxt to this_item's content
if theTxt contains targetWord then
-- do some stuff here
--
--
my letsDoNumbers(a, b, c, d, e)
end if
end if
set read status of this_item to true
-- deselect the message here?

end tell
end repeat
end perform mail action with messages
end using terms from


on letsDoNumbers(p, q, r, s, t)
tell application "Numbers"
activate
open alias (my theSpreadsheet)
tell document "AppRevenue.numbers"
set this_sheet to (first sheet whose name is "A Sheet")
tell this_sheet
set _aTable to (first table whose name is "Table")


tell _aTable
set theRng to cell theCol of row theRow
add row above theRng
set theDataToBeAdded to {p, q, r, s, t}
set theIterator to 1


repeat with i from 1 to 5
set this_item to item i of theDataToBeAdded
set theRng's value to this_item
set theCol to theCol + theIterator
set theRng to cell theCol of row theRow
end repeat
end tell
end tell
end tell
end tell
end letsDoNumbers



 _______________________________________________
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

  • Follow-Ups:
    • Re: oddities with a Mail rule & Numbers
      • From: Yvan KOENIG <email@hidden>
    • Re: oddities with a Mail rule & Numbers
      • From: Brian Christmas <email@hidden>
  • Next by Date: Re: oddities with a Mail rule & Numbers
  • Next by thread: Re: oddities with a Mail rule & Numbers
  • Index(es):
    • Date
    • Thread