2012-08-13 77 views
0

我想發送一個電子郵件從我的Android應用程序有HTML內容和圖像作爲attachment.My搜索結果顯示,它是不可能發送圖像使用標籤HTML.Iow我可以達到這個?.ie,我想要內容在HTML(這些是一些URL),併發送圖像作爲附件。提前如何發送電子郵件與Html內容和Android中的圖像

感謝

+2

你[做過研究(http://stackoverflow.com/questions/2007540/how-to-send-html-email)? – Eric 2012-08-13 05:23:13

回答

2

爲以圖片形式發送郵件做到這一點

使用Intent.ACTION_SEND從設備連接的圖像以電子郵件這樣

File F = new File("/sdcardpath/imagename.png"); 
Uri U = Uri.fromFile(F); 
Intent i = new Intent(Intent.ACTION_SEND); 
i.setType("image/png"); 
i.putExtra(Intent.EXTRA_STREAM, U); 
startActivity(Intent.createChooser(i,"Email:")); 

&發送HTML內容到郵件正文爲此

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
emailIntent.setType("text/html"); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); 
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body)); 
startActivity(Intent.createChooser(emailIntent, "Email:")); 
+0

在HTML(Body)中發送圖像怎麼樣? – user5716019 2016-02-23 07:00:40

+0

Please,Expliain tag inside body .. – user5716019 2016-02-23 07:01:13

2
String path = Images.Media.insertImage(getContentResolver(), bmp,"title", null); 
Uri screenshotUri = Uri.parse(path); 
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
emailIntent 
     .putExtra(android.content.Intent.EXTRA_EMAIL, emailAddresses); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); 
emailIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri); 
emailIntent.setType("image/png"); 
startActivity(Intent.createChooser(emailIntent, "Send email using")); 

它的有用發送郵件

相關問題