전자 메일 보내기 옵션을 사용하여 응용 프로그램을 설정하려고합니다. swift에서 이메일 보내기 3
import Foundation
import MessageUI
import UIKit
class emailClass: UIViewController, MFMailComposeViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
if !MFMailComposeViewController.canSendMail() {
print("Mail services are not available")
return
}
sendEmail()
}
func sendEmail() {
let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = self
// Configure the fields of the interface.
composeVC.setToRecipients(["[email protected]com"])
composeVC.setSubject("Hello!")
composeVC.setMessageBody("Hello this is my message body!", isHTML: false)
// Present the view controller modally.
self.present(composeVC, animated: true, completion: nil)
}
func mailComposeController(controller: MFMailComposeViewController,
didFinishWithResult result: MFMailComposeResult, error: NSError?) {
// Check the result or perform other tasks.
// Dismiss the mail compose view controller.
controller.dismiss(animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
그래서 나는이 메시지를 얻을 : "메일 서비스를 사용할 수없는"을
나는이 코드를 가지고있다. 이제 iCloud의 시뮬레이터 장치에 로그인했습니다 ... 그래서 그렇게해야한다고 생각하지만 그렇지 않습니다. 왜이 기능이 작동하지 않습니까? 당신은 나에게 무슨 일이 잘못되었는지, 앞으로 나아갈 수있는 방법을 말해 줄 수 있습니까?
당신이 이메일 주소로 장치를 구성 했
소스를 말한다? 그렇지 않다면 ... 그러면 문제가 해결 될 수 있습니다. –
시뮬레이터를 사용하고 있습니다. 전자 메일 주소로 장치를 구성하려면 어떻게합니까? 내가 설정으로 갈 때 나는 옵션 "이메일"을 볼 수 없다 .... –
나는이 문제를 해결했다. 한편 iOS 장치를위한 이메일을 구성하는 링크는 ... https : // support. apple.com/en-in/HT201320 –