Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

Java
mimetype = "application/vnd.ms-outlook";


Method 2 : Fetching the MIMETYPE through `MimeTypeMap`

Java
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


Java
// Prints msg for extension and mimetype = application/vnd.ms-outlook for method 1 and null when i use method 2
 Log.i(TAG, "Extension :" + extension + "\n" + "MIME :" + mimetype); 
 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.
Posted
Updated 18-Nov-12 19:07pm
v2
Comments
TorstenH. 19-Nov-12 6:09am    
He already tried some things on StackOverflow: Question there.

I can't add in more than already said there.
But just to ask - WHY do you want to open *.msg-files on a android machine? I mean, it's not like they are there, or at least I don't know an "Outlook for Android".
Gopikrish T 19-Nov-12 22:39pm    
Hi TorstenH,

Thanks for your reply. Yeah, I have already tried with lot of ways to achieve the solution. Still, I couldn't able to find it.

I will try to make it more clear regarding my question. I am working on a file manager kind of application, in which i need to open an .MSG(Outlook item file) through a supportable installed application in the device. I came to know that i can able to open the .MSG file through the application called "Office Suite". Though , it is installed on my device, When i tried to open it through this application, Its not getting opened(Throws ActivityNotFoundException). but, When i open the same file(.MSG) which is attached in the email,"Office Suite" opens that file.

I hope, I have conveyed my query at the best. Please let me know your valuable suggestions.

Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900