I am trying to open a .MSG file through my application. I tried with setting the MIMETYPE as vnd.ms-outlook, still i couldn’t able to open up the .MSG file as i expected, then i tried with attaching the same .MSG in email and opened in my device. It opened like a charm.
So my question is , How can i open up the .MSG file in android programmatically within the application.
Tried with following methods,
Method 1 : Setting the MIMETYPE manually
mimetype = "application/vnd.ms-outlook";
Method 2 : Fetching the MIMETYPE through MimeTypeMap
String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString());
String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); // extension is msg
Opening the .MSG file through another installed application
Log.i(TAG, "Extension :" + extension + "\n" + "MIME :" + mimetype); // Prints msg for extension and mimetype = application/vnd.ms-outlook for method 1 and null when i use method 2
intent.setDataAndType(Uri.fromFile(file),mimetype);
startActivity(intent);
The mimetype in Method 2 results null and the mimetype set explicitly too doesn’t work.
Could anybody share their thoughts on solving this issue.
Thanks.
You should use an intent to open the file with another app. Try this:
That should allow any app that has registered the MSG’s data type in its manifest to open it.