Mailcore 2 iOS如何检索回复电子邮件地址

时间:2015-06-25 19:53:32

标签: ios objective-c mailcore2

Mailcore 2集成:

我正在制作"回复","全部回复" ,"转发"和移动到功能。当我开始使用"回复"时,我能够从MCOMessageView class - >获得回复邮件正文完整邮件。 content = [(MCOIMAPMessage *) _message htmlRenderingWithFolder:_folder delegate:self];并在回复中显示撰写视图。 现在,我需要预先填充"回复" (收件人)电子邮件在撰写视图中。当我尝试" _message.header.replyTo"时,它给了我喜欢" mailcore ::地址:0x17df0c70 getsy sandriya getsypri8796@gmail.com"

但是我需要单独从这个" _message.header.replyTo"中检索邮件地址,它给了我" mailcore ::地址:0x17df0c70 getsy sandriya getsypri8796 @ gmail .COM"

如何从" mailcore:........."中检索回复电子邮件地址,请提供建议。

1 个答案:

答案 0 :(得分:0)

对我来说,确切的答案如下,我做了一个快速的Swift v2.3示例,它运行如下:

let imapsession = MCOIMAPSession()
    imapsession.hostname = "YOUR SERVER"
    imapsession.port = 993
    imapsession.username = "EMAIL"
    imapsession.password = "PASS"
    imapsession.connectionType = MCOConnectionType.TLS

    let requestKind : MCOIMAPMessagesRequestKind = MCOIMAPMessagesRequestKind.Headers

    let folder : String = "INBOX"
    let uids : MCOIndexSet = MCOIndexSet(range: MCORangeMake(1, UINT64_MAX))

    let fetchOperation : MCOIMAPFetchMessagesOperation = imapsession.fetchMessagesOperationWithFolder(folder, requestKind: requestKind, uids: uids)

    fetchOperation.start { (err, msg, vanished) -> Void in
        print("error from server \(err)")
        print("fetched \(msg?[0]) messages")
        let msgs = msg
        if msgs?.count > 0 {
            for m in msgs! {
                let MSG: MCOIMAPMessage = m as! MCOIMAPMessage
                let op = imapsession.fetchMessageByUIDOperationWithFolder(folder, uid: MSG.uid)
                op.start { (err, data) -> Void in
                    let msgParser = MCOMessageParser(data: data)
                    let html: String = msgParser.plainTextBodyRendering()
                    print("*********************")
                    print("Mail body\(html)")
                    print("mail sender:\(MSG.header.sender)")
                    print("mail recipient:\(MSG.header.to)")
                    print("mail subject:\(MSG.header.subject)")
                    print("*********************")
                }
            }
        }
    }

在上面的示例中,我走了一段距离,我收集邮件内容作为文本。你也可以用HTML做。

希望这个答案可以帮助你并帮助其他陷入同一问题的人!