2012-09-04 2 views
0

Mail.app에서 전자 메일을 읽고 표시하는 Mac 응용 프로그램을 만들고 싶지만 Mail.app에서 메일을 읽는 방법에 대한 정보를 찾을 수 없습니다. 내 질문 :코코아 : Mail.app에서 메일 읽기

  1. Mail.app에서 전자 메일을 읽는 방법? 어떤 제안이라도 인정 될 것입니다.

    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); 
    

    대체 사용

답변

3

AppleScript를 예를 들어, 아마 가장 쉬운 방법입니다 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 
+0

참조 또한 ObjC에서이 작업을 수행하게됩니다 다리, 스크립팅 : 모든 메일을받을 수있는 방법이 http://robnapier.net/blog/scripting-bridge-265 –

+0

이를? '받은 편지함에 모든 메시지에 메시지 설정'과 같은 메시지가 표시됩니다. – NOrder

+0

모든 메시지를 반복하여 내용을 가져올 수 있습니다. 빠른 예가 추가되었습니다. – Anne

관련 문제