try out below code:
Note : You can only send html as attachment (not as email content)
private void shareFile(String subject,String body,String fileContent) {
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/html");
share.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
// Add data to the intent, the receiving app will decide
// what to do with it.
File tempFile ;
try {
File sdCard = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
File tempDir = new File (sdCard.getAbsolutePath() + "/temp-sample");
AppWebViewClient.deleteDirectoryFiles(tempDir); //delete temp files
tempDir.mkdirs();
tempFile = File.createTempFile("sample-records", ".html", tempDir);
FileOutputStream fout = new FileOutputStream(tempFile);
tempDir.setReadable(true, false);
tempFile.setReadable(true, false);
Uri uri = Uri.fromFile(tempFile.getAbsoluteFile());
share.putExtra(Intent.EXTRA_STREAM, uri);
fout.write(fileContent.getBytes());
fout.close();
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_SUBJECT, subject);
share.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(new StringBuilder().append(body).toString()));
// share.putExtra(Intent.EXTRA_TEXT, body);
context.startActivity(Intent.createChooser(share, "Share Records!"));
}