它仅在您右键单击邮件消息并选择“运行规则”时才有效,但不适用于传入消息(没有交互)。
第一个对话框在传入或手动运行时显示,但第二个对话框(带有 id)仅在手动运行时显示。console.log 中没有显示任何内容
有任何想法吗?
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with theMessage in theMessages
display dialog "inside"
set theId to id of theMessage
display dialog "the id is " & theId
end repeat
end tell
end perform mail action with messages
end using terms from
更新:我添加了一个 try catch 块
set theId to id of theMessage
这是我得到的错误:
Can't get class mssg 1 of class mbxp "Incoming POP messages" of class mact "Telenet". Invalid index. -1719
知道这意味着什么吗?手动应用规则时我没有收到错误消息。
更新 2:好的,我发现传入的消息还没有 ID。这是一个问题,因为我想将电子邮件保存到磁盘:
set theEmail to (do shell script "mdfind -onlyin ~/Library/Mail \"kMDItemFSName = '" & theId & ".emlx'\"")
set archiveName to theId & "-" & (extract address from theMessage's sender) & ".emlx"
set saveLocation to "Users:wesley:Documents:Incoming:"
do shell script "cp '" & theEmail & "' '" & POSIX path of saveLocation & "';"
有没有办法解决?