Sending emails from a macOS Objective-C App

I want to send from my app programmatically emails. I don't know how to use or set up:

@interface MFMailComposeViewController : UINavigationController

macOS Catalina, Xcode 11.0

Take a look at the "Configuring and Displaying the Composition Interface" section of the MSMailComposeViewController documentation: https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontroller?language=objc

There's a great example there.

If you want more information on View Controllers in general, check out the View Controller Programming Guide for iOS: https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/index.html

Hope this helps.
I know these links. These have been the starting point of my question. But how to implement in Objective-C:

@interface MFMailComposeViewController : UINavigationController ??

Everything, every manuals, every links I found center on iOS or Swift.
These links are no help to implement it in Objective-C code

Best regards
I suspect you’re mixing up your terminology here:
  • There’s Objective-C and Swift, and both can use MFMailComposeViewController equally well.

  • There’s macOS and iOS.

  • There’s UIKit, which runs on both [1], and AppKit, which runs just on iOS.

So, you’re using Objective-C, which nails down the first point. But what about the second and third points?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"

[1] On macOS, this is known as Mac Catalyst.
I visited again the link
https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontroller?language=objc

I inserted in my app the code line

Code Block MFMailComposeViewController* composeVC = [[MFMailComposeViewController alloc] init];

I got two error messages:
Use of undeclared identifier 'composeVC'
Use of undeclared identifier 'MFMailComposeViewController'

Please can you help me
Best regards

Obviously, the code line was missing in my reply just sent. Here is the code I inserted:

"MFMailComposeViewController* composeVC = [[MFMailComposeViewController alloc] init];"

Here is the code I inserted

OK, that confirms that you’re using Objective-C, which addresses my first point. What about the other two points:
  • What platform are you targeting, iOS or macOS?

  • What UI framework are you using, UIKit or AppKit? Or perhaps SwiftUI?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Please apologise my delayed reply.
Platform: macOS
Framework:
#import <AppKit/AppKit.h>
#import <Cocoa/Cocoa.h>

Thanks for replying
Best Regard
Gerhard
MFMailComposeViewController is an iOS class. It’s available on macOS via Mac Catalyst but it is not available to AppKit apps.

In an AppKit app you have a couple of options:
  • You can use NSSharingService.

  • You can AppleScript, or Apple events directly, to script Mail.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Sending emails from a macOS Objective-C App
 
 
Q