2016-08-23 4 views
2

MFMailComposeViewController를 사용하여 전자 메일을 보내지 만 전자 메일을 보낸 후 전자 메일 및 테이블 뷰에서 완료된 시간을 표시하려고합니다. 어떻게해야합니까?보낸 이메일에서 보낸 전자 메일과 타임 스탬프를 테이블 뷰에 저장하십시오.

내 테이블 코드는이

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) 
} 

가 어떻게 내 테이블에 표시 할 보낸 이메일과 시간을 얻을 수있는 메일 내 코드입니다

//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 
} 

기본입니까? 미리 감사드립니다.

답변

0

MFMailComposeViewController은 프로세스가 실행되지 않으며 디자인 상 완료 상태를 제외하고는 더 이상 정보를 제공하지 않습니다.

자세한 내용을 보려면 직접 전자 메일 보내기를 구현해야합니다.이 작업은 제품의 핵심이 아니라면 강력히 권고하는 매우 지루한 작업 일 수 있습니다.

업데이트 내장 된 메일 작곡가를 사용하여 가져올 수 없습니다. 이메일 클라이언트를 다시 구현하려는 경우 다음과 같은 몇 가지 오픈 소스 클라이언트가 있습니다. http://libmailcore.com; (사용자 계정에 대한 액세스 권한을 부여하지 않으므로 처음부터 계정을 설정해야합니다.) 또는 클라이언트에서 UI 만 제공하는 서버 또는 타사 서비스에서 이메일을 전송할 수 있습니다 (예 : 타사 서비스 https://github.com/sendgrid/sendgrid-objc

+0

그래서 내가 보낸 시간과 이메일을 어떻게받을 수 있습니까? 나는이 정보 만 필요로했다. 나는 매우 익숙하지 않기 때문에 매우 익숙하지 않아 어떻게 작동하는지 알 수 없다. – art3mis

+0

내 대답 –

+0

에 대한 업데이트를 참조하십시오. 업데이트 해 주셔서 감사합니다. 방금 아이디어를 주셨습니다. 완료 영역에서 방금 사용했던 전자 메일과 현재 NSDate를 보내고 배열로 전송할 수 있습니다. 그것을하는 방법을 모르지만, 좋은 생각 같아. – art3mis

관련 문제