1

I would like to download email files into the cordova.file.cacheDirectory and open them in the default email app. I am using the Cordova File Transfer Plugin for the download and the File Opener Plugin to open in the default app. The download part is working fine, however the File Opener plugin is giving the following error:

Error status: 9 - Error message: Could not handle UTI

The file I am trying to open is MIME formatted (.eml extension) and I am using the MIME type of message/rfc822:

function openFileWithDefaultApp(fileEntry) {
    var fileUrl = fileEntry.toURL();
    cordova.plugins.fileOpener2.open(
        fileUrl,
        'message/rfc822', {
            error: function (e) {
                console.log(
                    'Error status: ' + e.status +
                    ' - Error message: ' + e.message);
            },
            success: function () {
                console.log('file opened successfully');
            }
        }
    );
}

What am I missing?

P.S. This code is working perfectly with PDF files. Simply switching to email files is causing this issue. I am wondering if there is a "default app" for .eml files or do I have to switch some other format? One possibility is to convert emails to PDF, but that would loose attachments. Hence this is not preferable.

Naresh
  • 23,937
  • 33
  • 132
  • 204

1 Answers1

0

It's not possible to open .eml on iOS (see https://discussions.apple.com/thread/3709613?start=0&tstart=0) without a specific app (eg Klammer or 'EML Viewer').

An alternative is to convert the .EML to a .PDF on a server, for which there are probably OS options (such as https://github.com/nickrussler/eml-to-pdf-converter).

Jim W
  • 4,866
  • 1
  • 27
  • 43
  • Thanks, Jim. This is very useful. I finally found an app that can open .eml and .msg files - [Msg Viewer Pro](https://itunes.apple.com/us/app/msg-viewer-pro/id1019539949?mt=12). It opens .eml files from Dropbox etc using a tray interface. Unfortunately, it is not triggered from File Opener 2 - I think because it is not using the tray to open the app. File Opener 2 tries to get a UTI based on file extension or MIME type, both of which return a UTI of "com.apple.mail.email". This unfortunately does not trigger Msg Viewer Pro. – Naresh Dec 02 '17 at 18:01