OSXアプリケーションから電子メールを送信するのにNSAppleScriptを使用しています。 以前はうまくいきましたが、今はSierra 10.12.6で新しいXCode 9.0を使用するときに問題が1つあります。アプリケーションは電子メールを作成し、電子メールとメッセージの内容を含むMailウィンドウを開きますが、SENDは実行されません。私は送信ボタンをクリックすることができ、すべては問題ありません。メールは送信されますが、私は手動のクリック送信ボタンアクションを避けたいと思います。私は資格を使用していますSierraでNSAppleScriptを使用する - 動作しないアクションを送信する
:
<plist version="1.0">
<dict>
<key>com.apple.security.scripting-targets</key>
<dict>
<key>com.apple.mail</key>
<array>
<string>com.apple.mail.compose</string>
</array>
</dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
そして、これはコードです:
NSString *emailString = [NSString stringWithFormat:@"\
tell application \"Mail\"\n\
set newMessage to make new outgoing message with properties {subject:\"%@\", content:\"%@\" & return} \n\
tell newMessage\n\
set visible to false\n\
set sender to \"%@\"\n\
make new to recipient at end of to recipients with properties {name:\"%@\", address:\"%@\"}\n\
tell content\n\
",subjectt, bodyText, @"Company", toAddress, toAddress];
emailString = [emailString stringByAppendingFormat:@"\
end tell\n\
set visible to false\n\
send newMessage\n\
end tell\n\
end tell"];
NSLog(@"%@",emailString);
NSAppleScript *emailScript = [[NSAppleScript alloc] initWithSource:emailString];
[emailScript executeAndReturnError:nil];
だから、すべてのものが整備されているが、アクションは失敗して送信してください。 もう一度古いOSXバージョンでうまくいきました。 私には資格がないのですか?
ありがとうございました!
ありがとうございました!コードを変更した後:send \ n \同じ結果が出ます。変わりはない。 – rrodic