osx - How to open mail panel in Swift? Mac OS -


for past few days i've been strugling finding way send emails app. sample code using. think, using method, might unable handle situation of improper setting of mail accound of computer app running, thought using different method. wondering if there messageui equivalent mac os. there messageui equivalent mac os. ideas?

there 2 ways that:

  1. applescript framework

  2. nssharingservice

nssharingservice compose mail:

let service = nssharingservice(named: nssharingservicenamecomposeemail)  service?.recipients = ["test@gmail.com"] service?.subject = "test mail" service?.performwithitems(["test mail body"]) 

launch mail app

if want open mail app, try below code:

nsworkspace.sharedworkspace().launchapplication("mail") 

improper setting:

  • if account not configured on system, code show configuration window mail
  • when user try send mail it'll shown improper setting related error mail app need not bother it
  • if want use other mail app, try own mail system, native mail client or third party mail framework.

try terminal:

you can use shell script send mail using native client

mail -s "hello" "test@gmail.com" <<eof hello, test! eof 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -