• 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: Modifying incoming mail subject
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modifying incoming mail subject


  • Subject: Re: Modifying incoming mail subject
  • From: Michaël Grünewald <email@hidden>
  • Date: Thu, 27 Dec 2007 18:33:16 +0100


Le 27 déc. 07 à 00:30, has a écrit :

Tip: always ensure local variable names are different to application-defined keywords; syntax highlighting should help you tell the difference.

Thank you for that tip, this was a quite silly error ... I regret I did not get a sensible warning about his! By the way, is there any facility in the script editor that can help one to spot its mistake (e.g. a list of variables used in a script can let one spot spelling errors)?


As far as bridges go, AppleScript integration is not great: see osascript for shell-to-AppleScript, and 'do shell script' for AppleScript-to-shell, although you'll find them rather lacking. There should be a couple of basic OSA language components for sh kicking around somewhere, but without integrated Apple event IPC support their usefulness will be extremely limited [2]. Your best bet may be Python or Ruby, which can live fairly comfortably in both worlds and come with plenty of Unixy goodness already included. The best Apple event bridge currently available for those languages is appscript. It requires separate installation, but this is pretty straightforward. See my sig. for links. (There are other options as well, although they're not as good.) OSA component support (needed for things like Mail rules) is still rather limited, unfortunately, although a new developer release of PyOSA will be out shortly which should be reasonably usable with a bit of care.

Thanks for these valuable information, I should pay much attention to ruby in the following days. My bet is that Ruby is easier to learn than Applescript (I have basics in many computer languages, but Applescript is quite disturbing --- or the guidebook quite unclear.)


Back to the problem of modifying incoming emails, my script is still not working. To get more clues I have put a few SAY orders in the script:
-- SCRIPT
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
say "Hello"
set text item delimiters to "[Caml-list] "
repeat with eachMessage in theMessages
say "This goes on and on"
set theSubject to the subject of eachMessage
set theAnswer to ""
repeat with thePart in text items of theSubject
set theAnswer to theAnswer & thePart
end repeat
set subject of eachMessage to (theAnswer)
end repeat
end tell
end perform mail action with messages
end using terms from
-- SCRIPT


When I ask Mail to apply rules, I can hear the "hello" that let me know the script is triggered, but there is no iteration of the loop. Semantics of the code I wrote is unclear to me because I merely patched together lines that I found here and there on the www.
--
All the best,
Micha







___________________________________________________________________________ Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire. http://fr.mail.yahoo.com _______________________________________________ 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: Modifying incoming mail subject
      • From: "Gary (Lists)" <email@hidden>
    • Re: Modifying incoming mail subject
      • From: has <email@hidden>
    • Re: Modifying incoming mail subject
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Modifying incoming mail subject (From: Michaël Grünewald <email@hidden>)
 >Re: Modifying incoming mail subject (From: has <email@hidden>)

  • Prev by Date: Re: Automated sending of emails
  • Next by Date: Re: Automated sending of emails
  • Previous by thread: Re: Modifying incoming mail subject
  • Next by thread: Re: Modifying incoming mail subject
  • Index(es):
    • Date
    • Thread