gpt4 book ai didi

cocoa - 使用脚本桥创建邮件

转载 作者:行者123 更新时间:2023-12-03 17:29:35 26 4
gpt4 key购买 nike

我正在尝试使用 cocoa 脚本桥创建一封新电子邮件,但似乎无法让它工作。到目前为止我已经:

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]

当我为应用程序添加沙箱时出现此问题。谁能指出正确的方向吗?

最佳答案

如果您的代码可以在启用沙箱之前运行,那么您应该在发送邮件之前先执行此操作。将以下代码添加到您的 Entitlements.plist 中。

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

关于cocoa - 使用脚本桥创建邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11927800/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com