Is there a way to include fields such as "BCC" and "CC" using NSSharingService?

334 views Asked by At

Im wondering if there is a way to compose an email in Swift and have it populate fields such as CC and BCC.

Currently I am using NSSharingService and it only appears to have the options for Recipient, Subject, and Body.

I'm not married to using NSSharingService, but I would like to know a way to implement what I am trying to do.

EDIT: I am developing for Mac and not iOS

class SendEmail: NSObject {
    static func send(recipient: String) {
        let service = NSSharingService(named: 
        service.recipients = ["Recipient Goes Here"]
        service.subject = "Subject Goes Here"
        service.perform(withItems: ["Body Goes Here"])
    }
}
1

There are 1 answers

1
pompopo On

This works in Swift5 (Xcode 10.2.1, macOS 10.14.5)

let url = URL(string: "mailto:[email protected]?subject=subject&[email protected]&[email protected]")!
NSWorkspace.shared.open(url)