1

我想在电子邮件中将 vcf 文件作为附件发送。这适用于默认邮件应用程序(在 HTC One X 上),但不适用于 Gmail 应用程序。

Gmail 应用程序会弹出并显示要发送的邮件,包括作为附件的 vcf 文件。但是当我按发送时,应用程序崩溃并且不发送电子邮件。

如果不包含附件,则电子邮件将正确发送。vcf 文件由应用程序创建并存储在 sd 卡上。这是发送电子邮件的代码:

Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"email@gmail.com"});          
email.putExtra(Intent.EXTRA_SUBJECT, "title");
email.putExtra(Intent.EXTRA_TEXT, "content");
File rootDirectory = new File(Environment.getExternalStorageDirectory(), "exStorageDirectory");
Uri screenshotUri = Uri.parse(rootDirectory + "/vcardFile.vcf");
email.putExtra(Intent.EXTRA_STREAM, screenshotUri);             
email.setType("text/vcard");
startActivity(email);

我已经尝试过使用各种 setType 输入,但它们似乎没有什么区别:email.setType("message/rfc822"); email.setType("image/jpeg"); email.setType("vnd.android.cursor.dir/email");
email.setType("application/x-vcard"); email.setType("text/html"); email.setType("text/plain");

screenshotUri是因为没有它,Gmail 应用程序在打开时会直接崩溃。默认的邮件应用在这里也没有问题。

任何想法如何使它与 Gmail 应用程序一起工作?谢谢你的帮助!

4

0 回答 0