我必须在电子邮件中嵌入来自SD卡的图像并发送它。我正在尝试使用HTML标签,但它不能正常工作。任何人都可以帮助我吗?
答案 0 :(得分:0)
这会对你有所帮助
File myDir=new File("/sdcard/Download");
myDir.mkdirs();
String fname = "Image.jpg";
File file = new File (myDir,fname);
try {
FileOutputStream out = new FileOutputStream(file);
finalBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
// finalBitmap means sending image.
out.flush();
out.close();
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("Image/jpg");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Greetings");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Hi");
File downloadedPic = new File(Environment.getExternalStoragePublicDirectory
(Environment.DIRECTORY_DOWNLOADS),"image.jpg");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
Full.this.startActivity(Intent.createChooser(emailIntent, "send"));
} catch (Exception e) {}