swift - Get email and time stamp from sent emails saved on a tableview -
im using mfmailcomposeviewcontroller send emails, after sent email show email , time done on tableview. how can that?
my table code basic
//this empty, populate empty table 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 }
this code mail
func contactpicker(picker: cncontactpickerviewcontroller, didselectcontactproperty contactproperty: cncontactproperty) { //checks if composer can sent email if mfmailcomposeviewcontroller.cansendmail() { let mail = mfmailcomposeviewcontroller() mail.mailcomposedelegate = self //add email recipient field if let emailaddress = contactproperty.value as? string { mail.settorecipients([emailaddress]) } //dismisses current view , presents mail composer view self.dismissviewcontrolleranimated(true, completion: {() -> void in self.presentviewcontroller(mail, animated: true, completion: nil) }) } else { print("send error") } } //dismiss buttons 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) }
how can sent email , time show on table? thank in advance.
mfmailcomposeviewcontroller
runs out of process, , design not provide more information except completion status.
if want more information, you'll need implement sending emails manually might tedious task i'd advise against unless core of product.
update can not using built in mail composer. if prefer reimplement email client, there several open source clients: http://libmailcore.com; (keep in mind won't have access user accounts forcing set account scratch). alternatively can implement sending email server or 3rd party service providing ui on client, e.g. 3rd party services https://github.com/sendgrid/sendgrid-objc
Comments
Post a Comment