2012-11-15 110 views
1

我目前正在嘗試自定義正在讀取收件箱中的未讀郵件的AppleScript。 基本上工作正常,除了事實,我可以#設法得到郵件的日期。通過AppleScript獲取電子郵件的日期

約2小時,周圍的Googling後,我發現,試圖用其中的一個,當我需要應receivedate或deliverydate,但可變我得到一個錯誤這樣的:

"...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 

回答

3

你正在尋找的期限爲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 

更快的方法來獲得你所需要的幫助是郵件的AppleScript的dictionarie 。 Mail的所有命令,類和屬性都在本字典中。

打開此字典的一種方法是使用AppleScript EditorFile菜單中的打開字典項目。當你使用這個項目時,你會得到一個有字典的可用應用程序列表。選擇Mail並單擊打開按鈕或使用瀏覽按鈕導航到未列出的應用程序。

另一種打開字典的方法是利用AppleScript Editor's庫窗口。它位於結果歷史和事件日誌歷史記錄菜單項下方的Window菜單中。 「庫」窗口顯示可通過雙擊打開的字典的默認應用程序列表。

+0

啊,是的,這就是我正在尋找的! 圖書館窗口也一樣 - 正在搜索類似這樣的難題,我錯過了看看編輯器本身-.-' 非常感謝! –

相關問題