我在我的项目中使用库mailcore2(http://libmailcore.com/api/objc/index.html)。我想在WKWebView中呈现消息(电子邮件)的主体。当我呈现HTML消息正文时,webView通过将内容HTML缩小得太多来加载内容HTML。我该如何解决?是由于消息的内容吗?还是呈现邮件正文HTML的方法?现在,我仅使用库mailcore2的MCOIMAPSession类实现了IMAP协议。谢谢
屏幕截图:https://i.ibb.co/pb1xG0R/IMG-CA104358-B976-1.jpg
我执行以下操作:
var imapsession: MCOIMAPSession?
func getBodyOfEmail(message: MCOMessage, folder: String, completion: @escaping(String)->()) {
if mailProtocol == "IMAP" {
let op = self.imapsession!.htmlBodyRenderingOperation(with: message.imapMessage!, folder: folder)
print("IMAPSESSION: RENDERING \(message.uid) FOLDER \(folder)")
op?.start({ (body, error) in
if let error = error {
print("IMAPSESSION: ERROR \(error) HTML BODY RENDERING")
completion("")
} else {
if let body = body {
completion(body)
} else {
print("IMAPSESSION: ERROR HTML BODY RENDERING")
completion("")
}
}
})
}
MCOSession.shared.getBodyOfEmail(message: email, folder: folder) { (body) in
print("BODY: \(body)")
self.webView.loadHTMLString(body, baseURL: nil)
}
class MCOMessage {
var mailProtocol: String // IMAP or POP
var imapMessage: MCOIMAPMessage?
var popMessage: MCOPOPMessageInfo?
var uid: UInt32
var sequenceNumber: UInt32
var flags: MCOMessageFlag
var header: MCOMessageHeader
var plainText: String?
// I have only implemented the imap protocol
init(mailProtocol: String, message: MCOIMAPMessage) {
self.mailProtocol = mailProtocol
self.imapMessage = message
self.uid = message.uid
self.sequenceNumber = message.sequenceNumber
self.flags = message.flags
self.header = message.header
}
}