我使用MFMailComposeViewController发送电子邮件,但在您发送电子邮件后,我想在桌面视图中显示电子邮件和时间。我怎么能这样做?
我的表格代码是基本的
//This is empty, just to populate the empty table for now
var sentEmails = [String]()
//Number of Sections
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
//Number of Rows
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return sentEmails.count
}
//Cell Configuration
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath)
let row = indexPath.row
cell.textLabel?.text = sentEmails[row] //Email here?
cell.detailTextLabel?.text = "time stamp"//maybe?
return cell
}
这是我的邮件代码
func contactPicker(picker: CNContactPickerViewController, didSelectContactProperty contactProperty: CNContactProperty) {
//Checks if composer can sent email
if MFMailComposeViewController.canSendMail() {
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
//Add the email to the recipient field
if let emailAddress = contactProperty.value as? String {
mail.setToRecipients([emailAddress])
}
//Dismisses the current view and presents the mail composer view
self.dismissViewControllerAnimated(true, completion: {() -> Void in
self.presentViewController(mail, animated: true, completion: nil)
})
} else {
print("send error")
}
}
//Dismiss Buttons for Mail Composer
func mailComposeController(controller:MFMailComposeViewController, didFinishWithResult result:MFMailComposeResult, error:NSError?) {
switch result {
case MFMailComposeResultCancelled:
print("Mail Cancelled")
case MFMailComposeResultSaved:
print("Mail Saved")
case MFMailComposeResultSent:
print("Mail Sent")
case MFMailComposeResultFailed:
print("Mail sent failure: \(error)")
default:
break
}
controller.dismissViewControllerAnimated(true, completion: nil)
}
如何获取已发送的电子邮件和时间以显示在我的桌面上?先感谢您。
答案 0 :(得分:0)
MFMailComposeViewController
用完了,并且除了完成状态之外,设计中不再提供任何其他信息。
如果您需要更多信息,您需要手动实施发送电子邮件,这可能是一项非常繁琐的工作,我强烈建议您不要这样做,除非这是您产品的核心。
更新您无法使用内置邮件编辑器获取它。如果您希望重新实现电子邮件客户端,则有几个开源客户端:http://libmailcore.com; (请记住,您无权访问用户帐户,迫使她从头开始设置帐户)。或者,您可以实施从您的服务器或第三方服务发送电子邮件,仅在客户端提供UI,例如第三方服务https://github.com/sendgrid/sendgrid-objc