I am trying to create a new email using the cocoa scripting bridge,but can not seem to get it to work.I have so far:
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];
}
When I try and set the visible property,I got the error message:
-[SBProxyByClass setVisible:]: object has not been added to a container yet; selector not recognized [self = 0x7fd4fae3cc90]
This issue appeared when I added the sandbox for app. Can anyone point the correct direction?