0
我想製作一個從Mail.app中讀取電子郵件並顯示它們的Mac應用程序,但是我找不到有關如何從Mail.app中讀取郵件的任何信息。我的問題是:可可:從Mail.app中讀取郵件
- 如何從Mail.app中讀取電子郵件?任何建議,將不勝感激。
我想製作一個從Mail.app中讀取電子郵件並顯示它們的Mac應用程序,但是我找不到有關如何從Mail.app中讀取郵件的任何信息。我的問題是:可可:從Mail.app中讀取郵件
AppleScript的可能是最簡單的方法,例如:
tell application "Mail"
set theMessage to message 1 of inbox
set theBody to content of theMessage as rich text
end tell
貫穿NSAppleScript
腳本,快速骯髒的例子(沒有錯誤處理等):
NSString *theSource = @"tell application \"Mail\"\n"
"set theMessage to message 4 of inbox\n"
"set theBody to content of theMessage as rich text\n"
"end tell\n"
"return theBody";
NSAppleScript* theScript = [[NSAppleScript alloc] initWithSource:theSource];
NSAppleEventDescriptor* theDescriptor = [theScript executeAndReturnError:NULL];
NSLog(@"%@", theDescriptor);
其它用途osascript
到NSTask
運行腳本。
編輯通過所有消息(迴應評論)
環路和自己的身體增加了theMessages
列表。
set theMessages to {}
tell application "Mail"
set theCount to get the count of messages of inbox
repeat with theIncrementValue from 1 to theCount by 1
set TheMessage to message 1 of inbox
set theBody to content of TheMessage as rich text
set end of theMessages to theBody
end repeat
end tell
return theMessages
參見腳本橋,你在ObjC做到這一點,這將讓:http://robnapier.net/blog/scripting-bridge-265 –
有沒有辦法讓所有的郵件?像'設置郵件消息所有的收件箱'? – NOrder
您可以遍歷所有消息獲取其內容。新增了一個快速示例 – Anne