2
我可以使用什麼類型的意圖發送帶有HTML頁面附件的電子郵件?我使用什麼類型,發送的郵件中包含一個空白頁作爲附件發送一個HTML文件作爲附件
下面是一些代碼
String root = "/data/data/com.email/files/";
String fileName = "Payslip.html";
if (true) {
attachment = new File(root, fileName);
}
final Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND);
emailIntent.setType("application/octet-stream");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { address.getText().toString() });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
subject.getText());
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
emailtext.getText());
emailIntent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(attachment));
EmailActivity.this.startActivity(Intent.createChooser(
emailIntent,
"Send mail..."));
代替emailIntent.setType( 「應用程序/八位字節流」);嘗試emailIntent.setType(「file/html」); – pixelscreen 2012-07-30 07:30:26
[嘗試看到這裏](http://stackoverflow.com/a/3586478/940096) – Praveenkumar 2012-07-30 07:41:56
看來你的代碼是正確的。我使用它來發送生成的PDF文件。你確定文件Payslip.html不是空的嗎?只需創建一個簡單的Web視圖,並在應用程序中查看此文件。 – 2012-07-30 07:43:50