Thanks for the reply. Here is the code. Although we have been doing this for seven years and have 17 iOS apps we pretty much operate in the Xcode/Objective C and occasionally the Swift world.
Here is the link to the actual project: https://developer.apple.com/library/archive/samplecode/SBSendEmail/Introduction/Intro.html#//apple_ref/doc/uid/DTS10004645
Here is the one method in the project that does what we need. Adds a message to the outgoing messages.
- (IBAction)sendEmailMessage:(id)sender {
/* create a Scripting Bridge object for talking to the Mail application */
MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.Mail"];
/* set ourself as the delegate to receive any errors */
mail.delegate = self;
/* create a new outgoing message object */
MailOutgoingMessage *emailMessage = [[[mail classForScriptingClass:@"outgoing message"] alloc] initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
[self.subjectField stringValue], @"subject",
[[self.messageContent textStorage] string], @"content",
nil]];
/* add the object to the mail app */
[[mail outgoingMessages] addObject: emailMessage];
/* set the sender, show the message */
emailMessage.sender = [self.fromField stringValue];
emailMessage.visible = YES;
/* Test for errors */
if ( [mail lastError] != nil )
return;
/* create a new recipient and add it to the recipients list */
MailToRecipient *theRecipient = [[[mail classForScriptingClass:@"to recipient"] alloc] initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
[self.toField stringValue], @"address",
nil]];
[emailMessage.toRecipients addObject: theRecipient];
[theRecipient release];
/* Test for errors */
if ( [mail lastError] != nil )
return;
}
/* send the message */
[emailMessage send];
}