The code is as follows:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setData(Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
context.startActivity(Intent.createChooser(intent, "Share it."));
Copy the code
Compatibility reference: https://www.jianshu.com/p/9520161ffb05 https://blog.csdn.net/zhizuyiwang/article/details/51547403Copy the code