We are using the SBSendEmail Apple code to create an email to be sent by email app.
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];
Getting this error:
[General] *** -[SBProxyByCode setSender:]: object has not been added to a container yet; selector not recognized [self = 0x600000c85bf0]
Any help with getting this working or an alternate solution would be greatly appreciated!
Thanks John
Here is the answer from ATS:
The Scripting Bridge sample you pointed to has not been updated in several years, and is now archived. It likely has several isues that prevent it from working as originally designed, and there are no current plans to update it to work with the latest operating systems.
Rather than using scripting bridge, I recommend using Applescript directly, for example, this code:
You can embed this code and call it from your app using the examples described in this Apple Developer Forums post:
https://forums.developer.apple.com/message/301006#301006