我们正在使用 SBSendEmail Apple 代码来创建要通过电子邮件应用程序发送的电子邮件。
MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.Mail"];
mail.delegate = self;
MailOutgoingMessage *emailMessage = [[[mail classForScriptingClass:@"outgoing message"] alloc] initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
[self.subjectField stringValue], @"subject",
[[self.messageContent textStorage] string], @"content",
[self.fromField stringValue], @"sender",
nil]];
[[mail outgoingMessages] addObject: emailMessage];
MailToRecipient *theRecipient = [[[mail classForScriptingClass:@"to recipient"] alloc] initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
[self.toField stringValue], @"address",
nil]];
[emailMessage.toRecipients addObject: theRecipient];
[emailMessage send];
出现此错误:
[General] *** -[SBProxyByCode setSender:]: 对象还没有被添加到容器中;选择器无法识别 [self = 0x600000c85bf0]
如果您能帮助我们解决此问题或提供替代解决方案,我们将不胜感激!
谢谢 约翰
最佳答案
从 Mojave 开始,您需要向用户解释为什么您要求访问 AppleScript。为此,请将其添加到您的 Info.plist 中:
<key>NSAppleEventsUsageDescription</key>
<string>MyApp needs to control ___ because ___</string>
Daniel Jalkut 写道 a good blog post在 Mojave 处于测试阶段时关于此问题。
关于objective-c - 用于发送电子邮件的脚本桥 - 错误 : Object not added to container yet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57346621/