2012-08-13 8 views
0

나는 코코아 스크립트 브리지를 사용하여 새 이메일을 만들려고하고 있지만, 일하러 지금까지 가지고 그것을 얻을 수없는 것 :스크립트 다리 메일을 만들

MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.Mail"]; 
MailOutgoingMessage *emailMessage = [[[[mail classForScriptingClass:@"outgoing message"]  alloc] initWithProperties:[NSDictionary dictionaryWithObjectsAndKeys: [saveFileName substringToIndex:[saveFileName length]-4], @"subject", @"something about app.", @"content", nil]] autorelease]; 
// add the object to the mail app 
[[mail outgoingMessages] addObject: emailMessage]; 
emailMessage.visible = YES; 

if ([FileFullName length] > 0) { 

    MailAttachment *theAttachment = 
    [[[mail classForScriptingClass:@"attachment"] alloc] 
    initWithProperties:[NSDictionary dictionaryWithObjectsAndKeys: 
         FileFullName, @"fileName",nil]]; 
    // add it to the list of attachments 
    [[emailMessage.content attachments] addObject: theAttachment]; 
    [theAttachment release]; 
} 

을 나는 시도하고 설정하는 경우 나는 앱 샌드 박스를 추가 할 때이 문제가 나타

-[SBProxyByClass setVisible:]: object has not been added to a container yet; selector not recognized [self = 0x7fd4fae3cc90] 

: visible 속성, 나는 오류 메시지를 받았습니다. 누구나 올바른 방향을 가리킬 수 있습니까?

답변

6

당신이 샌드 박스를 사용하기 전에 코드가 작동 할 수있는 경우는 메일을 보내기 전에, 당신이 처음이 작업을 수행해야합니다. 다음 코드를 Entitlements.plist에 추가하십시오.

<key>com.apple.security.temporary-exception.apple-events</key> 
    <array> 
    <string>com.apple.mail</string> 
    </array>