Send an email with the Android app. Works in Gmail, but not in Outlook

So, from my Android app, I can send emails with the app in Gmail. In Outlook, it looks like it is attaching a file (.txt), but when I open the mail, there is no attached file.

This is my code:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
Uri uriFileToShare = Uri.fromFile(file);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, file.getName());
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, uriFileToShare);
this.startActivityForResult(Intent.createChooser(emailIntent, activity.getString(R.string.send)+" "+file.getName()+" "+activity.getString(R.string.by_email)),code);

I tried different solutions, but no result.

The file, of course, exists and is not empty. As I said, Gmail is connected correctly.

Any idea?

+3
source share
1 answer

This code worked for me in the Outlook application.

public static void emailLog(Context context) {
    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("text/html");
    String filePath = fileDir + "/" + fileName;
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{""});
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
    File recordingFile = new File(filePath);
    Uri fileUri = Uri.fromFile(recordingFile);
    emailIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
    context.startActivity(Intent.createChooser(emailIntent, "Some text..."));
}
+1
source

All Articles