Open .msg and .eml files from iOS UIWebview

2019-04-16 22:37发布

问题:

I am trying to display .msg and .eml files using iOS sdk 5.1 in a UIWebView. I have the files in a binary format (NSData). I am able to display doc, docx, ppt, pptx, xls, xlsx, pdf, png, bmp and jpg files in the UIWebView but not the .msg and .eml files.

Are msg and eml files supported by UIWebView? If not, is there some other way to display such files? They open fine from the Mail app.

I am getting the following error from webView:didFailLoadWithError:

2012-08-09 15:59:03.851 HelloWorld[5848:707] Error loading attachment Error Domain=WebKitErrorDomain Code=102 "Frame load interrupted" UserInfo=0x132f3ec0 {NSErrorFailingURLKey=file:///var/mobile/Applications/E959949D-1487-4AD5-A5AA-E6F678BD9D63/Documents/Your%20New%20Daily%20Edition.msg, NSErrorFailingURLStringKey=file:///var/mobile/Applications/E959949D-1487-4AD5-A5AA-E6F678BD9D63/Documents/Your%20New%20Daily%20Edition.msg, NSLocalizedDescription=Frame load interrupted}

回答1:

.MSG and .EML files aren't supported by UIWebView. I haven't seen any objective C libraries for either, but mimetic is a free C++ library that can do the job for EML files (and presumably MIME-compliant MSG files). If you haven't mixed the languages before, this article reviews the important stuff.

I haven't seen any non-Windows (Vbasic or C#) libraries for MSG files, and I understand they're difficult to parse because Outlook acts slightly differently on each version. (I'd love to be proven wrong here.)