使用Applescript获取有关电子邮件附件的信息

时间:2015-08-19 14:58:46

标签: macos applescript

我正在尝试接收有关邮件应用程序中附件的信息。到目前为止,我能够从所选的电子邮件中接收数据。但我还想收到有关附件的信息。

tell application "Mail"
    set selectedMessages to selection
    set theMessage to item 1 of selectedMessages
    set theMailbox to mailbox of theMessage
    set mailAddresses to email addresses of account of theMailbox
    return theAttachment in theMessage's mail attachments
end tell

如果我使用return mailAdresses,脚本就可以工作但我无法获得有关附件的信息。任何提示?

1 个答案:

答案 0 :(得分:1)

试试这个,返回值包含数据

  • theMessage
  • theMailbox
  • mailAddresses
  • 作为列表的所有附件的名称和mime类型

所有选定消息的每条消息

tell application "Mail"
    set selectedMessages to selection
    set mailBoxData to {}
    repeat with aMessage in selectedMessages
        set theMailbox to mailbox of aMessage
        set mailAddresses to email addresses of account of theMailbox

        set attachmentData to {}
        repeat with anAttachment in (get mail attachments of aMessage)
            tell anAttachment to set end of attachmentData to {name, MIME type}
        end repeat
        set end of mailBoxData to {theMessage, theMailbox, mailAddresses, attachmentData}
    end repeat
    return mailBoxData
end tell