The code above is for sending an email with an attachment made before(fileToSend2). Works fine below Android Nougat (7.0) but is not working in Android Nougat 7.0 and Oreo 8.0. I update my device to Nougat and it is not working. Maybe for safety reason I must use provider to share the Uri
file via intent. Can you help me how to do this?
Uri u1 = Uri.fromFile(fileToSend2);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "**Mail subject**");
sendIntent.putExtra(Intent.EXTRA_TEXT, "mail text");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"igirpenots55@yahoo.com"});
sendIntent.putExtra(Intent.EXTRA_STREAM, u1);
sendIntent.setType("text/html");
startActivity(sendIntent);