1

データを埋め込んだhtmlを介して、メール本文のインライン形式で画像を送信しようとしています。htmlは正しく表示されていますが、画像の代わりに画像が表示されています。「obj」と書かれた小さなブロックが表示されています。変換されたビットマップ img を base64 形式に変換します。コードは次のとおりです。

public void imageRetrieved(byte[] img) 
{
        Bitmap newImg=BitmapFactory.decodeByteArray(img,0,img.length);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();  
    newImg.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] b = baos.toByteArray();
    String imageEncoded = Base64.encodeToString(b,Base64.DEFAULT);

    Log.d("LOOK", imageEncoded);

    String txtBody = "<html><body><h1>hi it is stoneage product</h1><br><img src ='data:image/jpeg;base64,"+imageEncoded+"'/></body></html>";
    Log.d("data", txtBody);

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("text/html");           
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "testemail");    
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(txtBody));
    startActivity(Intent.createChooser(emailIntent, "Email:"));

}

親切に助けて

4

1 に答える 1