Applescript 获取邮件信息

问题描述 投票:0回答:1

这是我的脚本:

tell application "Mail"
    set theMessage to selection
    set theSubject to subject of theMessage
    set theBody to content of theMessage
end tell

我什至还没有让它做任何事情。我仍然在任何选定的消息上收到此错误:

tell application "Mail"
    get selection
        --> {message id 73707 of mailbox "INBOX" of account id "6E0B3832-1B5E-4689-9C8A-8D6294A0C4A4"}
Result:
error "Can’t get subject of {message id 73707 of mailbox \"INBOX\" of account id \"6E0B3832-1B5E-4689-9C8A-8D6294A0C4A4\" of application \"Mail\"}." number -1728 from «class subj» of {«class mssg» id 73707 of «class mbxp» "INBOX" of «class mact» id "6E0B3832-1B5E-4689-9C8A-8D6294A0C4A4"}

我做错了什么?

我尝试了很多变化,包括输入延迟命令。

email applescript
1个回答
0
投票

选择的不是一条消息,而是一条或多条消息的列表。试试这个:

tell application "Mail"
    set theSelection to the selection
    repeat with theMessage in theSelection
        set theSubject to subject of theMessage
        set theBody to content of theMessage
    end repeat
end tell
© www.soinside.com 2019 - 2024. All rights reserved.