Send Multipart message with android

326 Views Asked by At

I have a rfc822 message I have created in Android. I need to send it via email to the specified recipients:

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_EMAIL, emailAddresses.toArray(new String[0]));

    LightMimeEntity lightMimeEntity = makeMessage();

    byte[] messageBytes = getMessageAsByteArray(lightMimeEntity);

    intent.putExtra(Intent.EXTRA_STREAM, new String(messageBytes));

    startActivity(Intent.createChooser(intent, "Send mail..."));

This causes GMail to crash with a NullPointerException.

If I replace

    intent.putExtra(Intent.EXTRA_STREAM, new String(messageBytes));

with

    intent.putExtra(Intent.EXTRA_TEXT, new String(messageBytes));

it uses the rfc822 text as the message body, which is not satisfactory.

Is there a way to send a message of this type through the Android email system?

0

There are 0 best solutions below