【发布时间】:2023-09-01 14:29:02
【问题描述】:
我正在尝试使用 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]
当我为 app. 添加沙箱时出现此问题。 谁能指出正确的方向?
【问题讨论】:
标签: cocoa email scripting-bridge