2012-07-19 110 views
0

我知道這個問題已經在堆棧溢出問了,我環顧四周,但沒有得到任何線索。其實我有編寫代碼發送圖像文件作爲我的郵件的附件,它的工作正常。下面顯示了用於將imageFile作爲附件發送的代碼。任何人都可以告訴我在郵件正文中發送imageFile需要做什麼修改。任何線索都會有幫助。如何發送電子郵件正文中的圖像文件

用於發送圖像作爲附加文件

Uri imageUri = Uri.parse("content://" + CachedFileProvider.AUTHORITY + "/" + fileNameArray.get(position)); 

Intent intent = new Intent(android.content.Intent.ACTION_SEND); 
intent.setType("image/png"); 
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 

intent.putExtra(Intent.EXTRA_STREAM, imageUri); 
startActivity(Intent.createChooser(i, "Send email")); 
+0

你有這個解決方案嗎? – OMAK 2013-07-08 10:51:36

回答

0

嘗試使用以下意圖:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
emailIntent.setType("image/jpeg"); 
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] 
{"[email protected]"}); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, 
"Test Subject"); 
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, 
"go on read the emails"); 
Log.v(getClass().getSimpleName(), "sPhotoUri=" + Uri.parse("file:/"+ sPhotoFileName)); 
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ sPhotoFileName)); 
startActivity(Intent.createChooser(emailIntent, "Send mail...")); 
+0

但是,這將發送文件作爲一個attchment,我已經這樣做了。我想在郵件正文中發送圖像,而不是作爲附件 – AndroidDev 2012-07-19 15:02:47

相關問題