I am working on a concept in which I have to embed html table tag in email body.I tried some work around code it's working fine in 2.2 and 2.3 OS versions but the same code is not working in latest OS versions like 4.0 etc.
I also tried Spannable and Html.fromHtml()
but it's also not working.
Here is my code which is working on 2.2 and 2.3 OS versions:
//SEND EMAIL
private void sendEmail(String imageUri) throws WriterException{
//....................Prepare share email data.............................
int itemNumber=0;
titleBuffer=new StringBuffer();
titleBuffer.append("<html><body><table border="+"1"+"><tr border="+"0"+"><th>Item number</th>"+
"<th>Barcode</th>"+"<th>Product name</th>"+"<th>Quantity</th></tr>");
for(int i=0;i<_productList.size();i++){
itemNumber=i+1;
titleBuffer.append("<tr border="+"0"+"><td>"+itemNumber+"</td>"+
"<td>"+_productList.get(i).getProductBarcode()+"</td>"+"<td>"+_productList.get(i).getProductName()+"</td>"+
"<td>"+_productList.get(i).getProductQuantity()+"</td></tr>");
/*titleBuffer.append("<tr border="+"0"+"><td>"+itemNumber+"</td>"+
"<td>"+_productList.get(i).getProductBarcode()+"</td>"+"<td>"+_productList.get(i).getProductName()+"</td>"+
"<td>"+_productList.get(i).getProductQuantity()+"</td>"+"<td>"+
"<img src="+"/'data:image/png;base64, "+generateBarcodeImage(GenerateBarcode.encodeAsBitmap(_productList.get(i).getProductBarcode(),
BarcodeFormat.CODE_128, 600, 300))+"/'/></td></tr>");*/
}
titleBuffer.append("</table></body></html>");
SpannedString bar = new SpannedString(titleBuffer.toString());
if(_productList.size()==0){
titleBuffer.append("NA");
}
//..........................................................................
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,"");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Shopping List");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,titleBuffer.toString());
emailIntent.putExtra(Intent.EXTRA_STREAM, emailImageUri);
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
Also find the attached image which proves it worked in 2.2 and 2.3 OS versions.