5
我想通過電子郵件發送幾個文件。我發現這個 Android multiple email attachments using Intent但它確實工作,我沒有得到任何錯誤消息。它只是不附加文件(我也試圖發送只有一個文件,但我得到了相同的結果)。Android意圖:發送電子郵件附件
我有沒有監督過什麼。?你有什麼建議嗎?
private static void email (Context context, String emailTo, String emailCC,
String subject, String emailText, List<String> filePaths)
{
//need to "send multiple" to get more than one attachment
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/xml");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{emailTo});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailText);
//has to be an ArrayList
ArrayList<Uri> uris = new ArrayList<Uri>();
//convert from paths to Android friendly Parcelable Uri's
for (String file : filePaths)
{
File fileIn = new File(file);
// Uri u = Uri.fromFile(fileIn);
Uri u = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "blabla.xml"));
Log.v("bla", "filepath: " +u.toString());
uris.add(u);
Uri b = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "blabla.es"));
uris.add(b);
Log.v("bla", "filepath: " +b.toString());
}
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
context.startActivity(emailIntent);
}
的logcat:
03-06 16:08:50.940: INFO/ActivityManager(69): Starting: Intent { act=android.intent.action.SEND_MULTIPLE typ=text/xml cmp=com.android.email/.activity.MessageCompose (has extras) } from pid 436
03-06 16:08:52.130: INFO/ActivityManager(69): Displayed com.android.email/.activity.MessageCompose: +1s118ms
03-06 16:08:52.470: WARN/IInputConnectionWrapper(436): showStatusIcon on inactive InputConnection
明顯,但是,你確定你的文件路徑是正確的,並指向實際的文件? – dymmeh 2012-03-06 16:22:08
文件路徑正確 – user1252642 2012-03-06 16:28:11
大多數電子郵件程序將無法處理'text/xml' MIME類型。而且,大多數用戶不能讀取XML。請考慮使用「text/plain」或「text/html」電子郵件散文。 – CommonsWare 2012-03-06 17:23:58