我有一条在 Android 中创建的 rfc822 消息。我需要通过电子邮件将其发送给指定的收件人:
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..."));
这会导致 GMail 以NullPointerException
.
如果我更换
intent.putExtra(Intent.EXTRA_STREAM, new String(messageBytes));
和
intent.putExtra(Intent.EXTRA_TEXT, new String(messageBytes));
它使用 rfc822 文本作为消息体,效果并不理想。
有没有办法通过 Android 电子邮件系统发送这种类型的消息?