• 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
Mail script puzzlement
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mail script puzzlement


  • Subject: Mail script puzzlement
  • From: Jeremy Roussak <email@hidden>
  • Date: Tue, 21 Jun 2016 19:21:02 +0100

Hi,

I have a rule in Apple Mail which runs a script when an email is received whose subject starts with a particular text. There’s a screenshot of the rule here: https://www.dropbox.com/s/m49htc8qo3y1z20/Screenshot 2016-06-21 19.14.21.jpg?dl=0. 

I have several ChronoSync documents, which are supposed to run on a schedule. Sometimes they don’t, and I want to be able to send an email to trigger a script to run the appropriate sync. So subject “run cs 4d” will run the 4d sync, and “run cs all” will run all of them.

The script is below. The issue is that when an email is received which runs the rule, the single message passed to the script isn’t the one that triggered the rule. Am I doing something wrong?

Jeremy

using terms from application "Mail"


on perform mail action with messages msgs


repeat with msg in msgs
set syncName to msg's subject


my logit(syncName, false)

set syncName to syncName's last word


tell application "ChronoSync Scheduler"
set syncs to scheduled items
repeat with sync in syncs
set itsName to sync's description
ignoring case
if (itsName is equal to syncName) or (syncName is "all") then
Synchronize sync
tell application "Mail" to delete msg
end if
end ignoring
end repeat
end tell


end repeat


end perform mail action with messages


end using terms from


on logit(str, noNL)
if (noNL is true) then
set backC to "\\c "
else
set backC to ""
end if
do shell script "echo " & (quoted form of (str & backC)) & " >> ~/Downloads/csmail.txt"
end logit


Jeremy Roussak
email@hidden



 _______________________________________________
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: Mail script puzzlement
      • From: Brian Christmas <email@hidden>
    • Re: Mail script puzzlement
      • From: Christopher Stone <email@hidden>
  • Prev by Date: Re: What is Best Practice for Reading Files of Unknown Encoding?
  • Next by Date: Re: en-dash, em-dash, and the like
  • Previous by thread: Re: What is Best Practice for Reading Files of Unknown Encoding?
  • Next by thread: Re: Mail script puzzlement
  • Index(es):
    • Date
    • Thread