【问题标题】:Android Email Multiple Attachment issue on HTC ThunderboltHTC Thunderbolt 上的 Android 电子邮件多个附件问题
【发布时间】:2026-01-20 17:45:01
【问题描述】:

我的情况很奇怪。

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

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 等,但没有任何效果。

我在这里错过了什么?

【问题讨论】:

标签: android android-intent email-attachments htc-thunderbolt


【解决方案1】:

我遇到了同样的问题,我通过使用 http Mime 库作为多部分表单实体来修复它。

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

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

      这对我很有用,一定要指定消息类型,这就是 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"));
      

      【讨论】:

        【解决方案4】:

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

        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:"));
        

        【讨论】: