Почта “Не может продолжиться” для функции AppleScript

Я пытаюсь записать AppleScript для использования с Почтой (на Snow Leopard) для сохранения вложений изображения сообщений к папке. Основная часть AppleScript:

property ImageExtensionList : {"jpg", "jpeg"}
property PicturesFolder : path to pictures folder as text
property SaveFolderName : "Fetched"
property SaveFolder : PicturesFolder & SaveFolderName

tell application "Mail"
  set theMessages to the selection
  repeat with theMessage in theMessages
    repeat with theAttachment in every mail attachment of theMessage
      set attachmentFileName to theAttachment's name
      if isImageFileName(attachmentFileName) then
        set attachmentPathName to SaveFolder & attachmentFileName
        save theAttachment in getNonexistantFile(attachmentPathName)
      end if        
    end repeat
  end repeat
end tell

on isImageFileName(theFileName)
  set dot to offset of "." in theFileName
  if dot > 0 then
    set theExtension to text (dot + 1) thru -1 of theFileName
    return theExtension is in ImageExtensionList
  end if
  return false
end isImageFileName

Когда выполнено, я получаю ошибку:

ошибка "Mail получила ошибку: не Может продолжить isImageFileName". номер-1708

где ошибка-1708:

Событие не было обработано обработчиком событий Apple.

Однако, если я скопировать/вставить isImageFileName() в другой сценарий как:

property ImageExtensionList : {"jpg", "jpeg"}

on isImageFileName(theFileName)
  set dot to offset of "." in theFileName
  if dot > 0 then
    set theExtension to text (dot + 1) thru -1 of theFileName
    return theExtension is in ImageExtensionList
  end if
  return false
end isImageFileName

if isImageFileName("foo.jpg") then
  return true
else
  return false
end if

это хорошо работает. Почему Почта жалуется на это?

17
задан Paul J. Lucas 4 May 2010 в 16:58
поделиться