2017-04-17 51 views
-2

如何使用AppleScript在Outlook 2016 for Mac中顯示最新消息的內容?如何使用AppleScript閱讀最新的Microsoft Outlook 2016消息

我可以做這樣的事情:

tell application "Microsoft Outlook" 
    return unread count of messages 
end tell 

,但我得到一個錯誤:

error "Microsoft Outlook got an error: Can’t get unread count of every message." number -1728 from unread count of every message 

這是我的開始,但我不知道該怎麼從那裏做。

回答

0

這就是你如何做到的。據最近的消息內容寫入「第一消息content.txt」

on writeTextToFile(theText, theFile, overwriteExistingContent) 
    try 

     -- Convert the file to a string 
     set theFile to theFile as string 

     -- Open the file for writing 
     set theOpenedFile to open for access file theFile with write permission 

     -- Clear the file if content should be overwritten 
     if overwriteExistingContent is true then set eof of theOpenedFile to 0 

     -- Write the new content to the file 
     write theText to theOpenedFile starting at eof 

     -- Close the file 
     close access theOpenedFile 

     -- Return a boolean indicating that writing was successful 
     return true 

     -- Handle a write error 
    on error 

     -- Close the file 
     try 
      close access file theFile 
     end try 

     -- Return a boolean indicating that writing failed 
     return false 
    end try 
end writeTextToFile 

tell application "Microsoft Outlook" 
    set theMessage to first item of (get current messages) 
    get subject of theMessage 
    set theContent to (content of theMessage) 
end tell 

set theFile to (((path to desktop folder) as string) & "first-message-content.txt") 
writeTextToFile(theContent, theFile, true) 

您可以通過打開蘋果的腳本編輯器找到的Outlook 2016的所有操作,然後選擇文件>打開字典>的Microsoft Outlook 。

相關問題