24

I have a weird situation here.

I am trying to send emails with multiple attachments using the following piece of code.

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

This works fine and the implicit intent mechanism shows up a lot of options like Gmail, Skype, Messaging etc.

The problem is that the default Mail client does not show up on HTC Thunderbolt ( but works on other devices including HTC Incredible S ).

If I try to send a single attachment using Intent.ACTION_SEND, the default mail client shows up. I have tried setting content type to text/plain, appliation/octet-stream, message/rfc282 etc but none works.

What am I missing here?

Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
Mahadevan Sreenivasan
  • 1,144
  • 1
  • 9
  • 26

4 Answers4

1

I had the same issue, I Fixed it with using http Mime Library for multipart form entity.

here is the link to the file. http://hc.apache.org/httpcomponents-client-4.3.x/httpmime/apidocs/org/apache/http/entity/mime/HttpMultipart.html

Umer Kiani
  • 3,783
  • 5
  • 36
  • 63
0

Sounds like a bug in the Thunderbolt's version of Sense. Custom UIs for the win, am I right?

Anyway, I would look up what app actually does handle emails on the thunderbolt and put an if-statement to detect if the device is a thunderbolt. If it is, set the Intent's target class to whatever that is. If it's not, do what you're already doing.

Steven Schoen
  • 4,366
  • 5
  • 34
  • 65
0

This works great for me, be sure to specify the the message type, that is how the android os knows which broadcast to use.

     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"));
Asaf
  • 381
  • 4
  • 4
0

Try this. I think it will work.

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:"));
Exhausted
  • 1,867
  • 2
  • 23
  • 33