Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 已发送电子邮件,未使用swift(OSX)进行确认_Macos_Swift_Email - Fatal编程技术网

Macos 已发送电子邮件,未使用swift(OSX)进行确认

Macos 已发送电子邮件,未使用swift(OSX)进行确认,macos,swift,email,Macos,Swift,Email,我无法在OSX上使用Swift发送电子邮件 它几乎可以完成工作,但不发送电子邮件,在我的个人电脑上,它打开了谷歌Chrome以获取一些理由 这是我的密码 import Cocoa class ViewController: NSViewController, NSSharingServiceDelegate { override func viewDidLoad() { super.viewDidLoad() // Do any additional

我无法在OSX上使用Swift发送电子邮件

它几乎可以完成工作,但不发送电子邮件,在我的个人电脑上,它打开了谷歌Chrome以获取一些理由

这是我的密码

import Cocoa

class ViewController: NSViewController, NSSharingServiceDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override var representedObject: AnyObject? {
        didSet {
        // Update the view, if already loaded.
        }
    }

    @IBAction func mag(sender: AnyObject) {
        let body = "BODY EMAIL"
        let shareItems = [body] as NSArray

        var service = NSSharingService(named: NSSharingServiceNameComposeEmail)
        service?.delegate = self
        service?.recipients = ["email@address.com"]

        let subject = "Subject!"
        service?.subject = subject

        service?.performWithItems(shareItems as [AnyObject])
    }          

}

这段代码适用于我,它按预期打开了一个邮件窗口。你的问题可能是因为你已经将Chrome设置为默认的电子邮件客户端,而不是Apple的邮件。这段代码对我来说很有用,它会按预期打开一个邮件窗口。您的问题可能是因为您将Chrome设置为默认的电子邮件客户端,而不是Apple的邮件客户端。