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:
applescript
frameworknssharingservice
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
Post a Comment