Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sandboxing my App with Scripting Bridge to send email

I'm using a scripting bridge for sending mails from my Mac App. Now I need to sandbox the app and sending mails is not longer working while sandboxing is enabled.

Does anybody know how to fix that?

Thanks, Andreas

Code: `

/* create a Scripting Bridge object for talking to the Mail application */
    MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.Mail"];


/* create a new outgoing message object */
MailOutgoingMessage *emailMessage =
[[[mail classForScriptingClass:@"outgoing message"] alloc]
 initWithProperties:
 [NSDictionary dictionaryWithObjectsAndKeys:
  [self.subjectField stringValue], @"subject",
  [[self.messageContent textStorage] string], @"content",
  nil]];

/* add the object to the mail app  */
[[mail outgoingMessages] addObject: emailMessage];
...

`

like image 392
Andreas Prang Avatar asked Sep 02 '11 17:09

Andreas Prang


2 Answers

You can't use the ScriptingBridge with Sandboxing enabled. Please file a bug report. This is what Apple recommends, if Sandboxing is a problem for you and there are no other solutions. They might add entitlements (not just temporary exceptions) for the ScriptingBridge, but as of now there is no further information available.

There are Entitlements Keys, especially the com.apple.security.temporary-exception.apple-events key, you can add to your Entitlements.plist file, but the key for Apple Events is a temporary exception.
Unfortunately, I was unable to get ScriptingBridge working even with the correct entitlements set. I hope you're luckier than me.

Apple is going to require Sandboxing for all apps submitted to the Mac App Store starting on the 1st of November!

com.apple.security.temporary-exception.apple-events

like image 172
Fabian Kreiser Avatar answered Oct 17 '22 01:10

Fabian Kreiser


Add this code to your Entitlements.plist, I tested It's ok.I can get selected mail from Mail now.

    <key>com.apple.security.temporary-exception.apple-events</key>
    <array>
    <string>com.apple.mail</string>
    </array>
like image 44
6 1 Avatar answered Oct 16 '22 23:10

6 1