PS: hier eine Alternative…

Show Plain Text
  1. set desktopPath to POSIX path of (path to desktop)
  2.  
  3. tell application "Mail" to set theMessages to selection
  4. repeat with theMessage in theMessages
  5.   tell application "Mail"
  6.     set messageID to id of theMessage as string
  7.     set theMailbox to mailbox of theMessage
  8.     set receivedDate to date received of theMessage
  9.     set theAccount to account of theMailbox
  10.     set accountDirectoryPath to account directory of theAccount
  11.   end tell
  12.   set {dy, mt, yr} to {day, its month, year} of receivedDate
  13.   set theDate to (yr as text) & mt & dy
  14.   set messagePath to POSIX path of accountDirectoryPath & name of theMailbox & ".mbox"
  15.   try
  16.     set theFile to paragraph 1 of (do shell script "/usr/bin/find " & quoted form of messagePath & " -name " & messageID & "*.emlx")
  17.     set newFile to desktopPath & messageID & "_" & theDate & ".eml"
  18.     set pythonText to "emlx = open(\"" & theFile & "\", 'r'); elen = int(emlx.readline().rstrip()); email = emlx.read(elen); emlx.close(); neweml = open(\"" & newFile & "\", 'w'); neweml.write(email); neweml.close()"
  19.     do shell script "python -c " & quoted form of pythonText
  20.   end try
  21. end repeat



als script innerhalb von Mail musst du es in einen "rule-wrapper" packen, das sieht dann so aus
Show Plain Text
  1. using terms from application "Mail"
  2.   on perform mail action with messages theMessages for rule theRule
  3.    
  4.     repeat with theMessage in theMessages
  5.       set messageID to id of theMessage as string
  6.       set theMailbox to mailbox of theMessage
  7.       set receivedDate to date received of theMessage
  8.       set theAccount to account of theMailbox
  9.       set accountDirectoryPath to account directory of theAccount
  10.       set {dy, mt, yr} to {day, its month, year} of receivedDate
  11.       set theDate to (yr as rich text) & mt & dy
  12.       set messagePath to POSIX path of accountDirectoryPath & name of theMailbox & ".mbox"
  13.       try
  14.         set theFile to paragraph 1 of (do shell script "/usr/bin/find " & quoted form of messagePath & " -name " & messageID & "*.emlx")
  15.         set newFile to desktopPath & messageID & "_" & theDate & ".eml"
  16.         set pythonText to "emlx = open(\"" & theFile & "\", 'r'); elen = int(emlx.readline().rstrip()); email = emlx.read(elen); emlx.close(); neweml = open(\"" & newFile & "\", 'w'); neweml.write(email); neweml.close()"
  17.         do shell script "python -c " & quoted form of pythonText
  18.       end try
  19.     end repeat
  20.   end perform mail action with messages
  21. end using terms from

und das script muss im Ordner ~/Library/Application Scripts/com.apple.mail/ liegen (~ ist dein Benutzerordner)
----------
Gruss

Stefan