24

我这里有一个奇怪的情况。

我正在尝试使用以下代码发送带有多个附件的电子邮件。

Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND_MULTIPLE );
// emailIntent.setType( "plain/text" );
emailIntent.setType( "application/octet-stream" );
...
....
emailIntent.putParcelableArrayListExtra( Intent.EXTRA_STREAM, uris );

这工作正常,隐式意图机制显示了很多选项,如 Gmail、Skype、消息传递等。

问题是默认的邮件客户端不会出现在 HTC Thunderbolt 上(但可以在包括 HTC Incredible S 在内的其他设备上使用)。

如果我尝试使用 发送单个附件Intent.ACTION_SEND,则会显示默认邮件客户端。我尝试将内容类型设置为 text/plain、appliation/octet-stream、message/rfc282 等,但都没有。

我在这里想念什么?

4

4 回答 4

1

我遇到了同样的问题,我使用 http Mime Library 修复了多部分表单实体。

这是文件的链接。 http://hc.apache.org/httpcomponents-client-4.3.x/httpmime/apidocs/org/apache/http/entity/mime/HttpMultipart.html

于 2014-04-03T13:37:41.830 回答
0

听起来像是 Thunderbolt 版本的 Sense 中的一个错误。赢得胜利的自定义用户界面,对吗?

无论如何,我会在 Thunderbolt 上查找实际处理电子邮件的应用程序,并放置一个 if 语句来检测设备是否是 Thunderbolt。如果是,请将 Intent 的目标类设置为任何内容。如果不是,请做你已经在做的事情。

于 2012-07-30T17:05:28.227 回答
0

尝试这个。我认为它会起作用。

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("plain/text");

ArrayList<Uri> uris = new ArrayList<Uri>();

String[] filePaths = new String[] {image1 Path,image2 path};
for (String file : filePaths) {
    File fileIn = new File(file);
    Uri u = Uri.fromFile(fileIn);
    uris.add(u);
}

if ( !(app_preferences.getString("email", "") == null || app_preferences.getString("email", "").equals(""))) {
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {app_preferences.getString("email", "")});    
}

emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject name");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Please find the attachment.");
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

startActivity(Intent.createChooser(emailIntent, "Email:"));
于 2014-12-18T05:43:47.187 回答
0

这对我很有用,一定要指定消息类型,这就是 android 操作系统知道要使用哪个广播的方式。

     String email = "test@email.com";
    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] {email}); // could have multiple address
    intent.putExtra(Intent.EXTRA_SUBJECT, "Enter your subject here");
    intent.putExtra(Intent.EXTRA_TEXT, "message text as needed");
    ArrayList<Uri> arrayUri = new ArrayList<Uri>();
    arrayUri.add(Uri.parse("file://" + paths[0]));
    arrayUri.add(Uri.parse("file://" + paths[1]));
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, arrayUri);
    startActivity(Intent.createChooser(intent, "Any title to show on chooser"));
于 2014-02-03T13:10:06.357 回答