繁体   English   中英

通过AppleScript获取电子邮件的日期

[英]Get the Date of an Email via AppleScript

我目前正在尝试自定义正在读取收件箱中未读邮件的AppleScript。 这基本上工作得很好,除了事实,我可以#T设法得到邮件的日期。

在谷歌搜索大约2个小时后,我发现我需要的变量应该被接收或传递,但是当尝试使用其中一个时,我得到如下错误:

"...receivedate of id... cannot be converted to Type reference..."

有人有一个想法,我怎么能转换这个?

这是我目前的代码:

tell application "System Events"
    set processList to (name of every process)
end tell
if processList contains "Mail" then
tell application "Mail"
    if (unread count of inbox) > 0 then
        set messageList to (messages of inbox) whose read status is false
        set output to "Mails:" & return & return & ""
        repeat with itemNum from 1 to (unread count of inbox)
            set itemDate to (receivedate of item itemNum of messageList)
            set output to output & itemDate & " - " & (extract name from sender of item itemNum of messageList) & return & subject of item itemNum of messageList & return & return
        end repeat
    end if
end tell
else
set output to "ÄpplMäil isch aus..."
end if

您要查找的术语是date received

tell application "Mail" to if running then
    if (unread count of inbox) > 0 then
        set output to "Mails:" & return & return & ""
        repeat with thisMsg in (get messages of inbox whose read status is false)
            tell thisMsg to set output to output & (date received) & " - " & (extract name from sender) & return & subject & return & return
        end repeat
    end if
else
    set output to "ÄpplMäil isch aus..."
end if

获得所需帮助的更快捷方式是Mail的Applescript词典。 Mail的所有命令,类和属性都在此字典中。

打开此词典的一种方法是使用AppleScript Editor的“ File菜单中的“打开词典”项。 使用此项时,您将获得具有词典的可用应用程序列表。 选择“ Mail ,然后单击“打开”按钮或使用“浏览”按钮导航到不公开的应用程序。

打开字典的另一种方法是使用AppleScript Editor's Library窗口。 它位于“结果历史记录”和“事件日志历史记录”菜单项下方的“ Window菜单中。 “库”窗口显示默认应用程序列表,您可以通过双击打开其词典。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM