简体   繁体   English

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

[英]Get the Date of an Email via AppleScript

I am currently trying to customize an AppleScript that is reading the unread Mails in the Inbox. 我目前正在尝试自定义正在读取收件箱中未读邮件的AppleScript。 That basically works fine except the fact, that I can#T manage to get the date of the mails. 这基本上工作得很好,除了事实,我可以#T设法得到邮件的日期。

After about 2 hours of googling around I found out that the Variable I need should be receivedate or deliverydate, but when trying to use one of these I get an error like this: 在谷歌搜索大约2个小时后,我发现我需要的变量应该被接收或传递,但是当尝试使用其中一个时,我得到如下错误:

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

Someone's got an Idea, how I can convert this? 有人有一个想法,我怎么能转换这个?

And this is my current code: 这是我目前的代码:

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

The term you are looking for is date received 您要查找的术语是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

A quicker way to get the help you need is the Applescript dictionarie of Mail . 获得所需帮助的更快捷方式是Mail的Applescript词典。 All commands, classes and properties of Mail are in this dictionary. Mail的所有命令,类和属性都在此字典中。

One way of opening this dictionary is to use the Open Dictionary item in the File menu of AppleScript Editor . 打开此词典的一种方法是使用AppleScript Editor的“ File菜单中的“打开词典”项。 When you use this item, you will get a listing of the available applications that have dictionaries. 使用此项时,您将获得具有词典的可用应用程序列表。 Choose Mail and click the Open button or use the Browse button to navigate to an unlisted application. 选择“ Mail ,然后单击“打开”按钮或使用“浏览”按钮导航到不公开的应用程序。

Another way to open a dictionary, is to make use of AppleScript Editor's Library window. 打开字典的另一种方法是使用AppleScript Editor's Library窗口。 It's located in the Window menu below the Result History and Event Log History menu items. 它位于“结果历史记录”和“事件日志历史记录”菜单项下方的“ Window菜单中。 The Library window shows a list of default applications whose dictionaries you can open with a double click. “库”窗口显示默认应用程序列表,您可以通过双击打开其词典。

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

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