我已經生成了一個HTML代碼(包含<html><body></body></html>
標籤)作爲字符串。現在我想將這個HTML代碼作爲HTML發送給郵件。我的代碼如下。使用Android intent發送HTML郵件
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
intent.putExtra(Intent.EXTRA_SUBJECT, "I would like to buy the following");
intent.putExtra(Intent.EXTRA_TEXT, purchaseOrder());
startActivity(Intent.createChooser(intent, "sending mail"));
其中purchaseOrder()
是將具有完整HTML代碼的字符串傳給我的方法。但是,儘管GMail客戶端在我的Nexus1上打開,但它具有包含所有HTML標記的字符串,而不是實際的HTML視圖。我嘗試了以下,但得到錯誤。 GMail墜毀。
intent.putExtra(Intent.EXTRA_STREAM, purchaseOrder());
因爲你不能在內置的郵件應用程序,這種格式的郵件Intent方法可能無法實現。 – 2010-03-30 09:50:38
[如何發送HTML電子郵件](http://stackoverflow.com/questions/2007540/how-to-send-html-email) – 2013-03-01 09:23:15