I have the same problem, I am trying to send a file without saving it to the file system. I tried adding uri al stream data additionally:
String fileContent = "File Content"; emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("data://text/plain;base64,"+ _utils.Strings.base64_encode(fileContent)));
I used my own class to create base64 content, but I think it will also work with: http://developer.android.com/reference/android/util/Base64.html
In this case, it was a success that saw the downloaded file in my mail client.
But there are 2 problems: 1. I do not know how to determine the name for this file 2. An error occurs when I try to send a file and I receive mail without an attachment on the other end.
UPDATE 2015-05-13: The mail application displays the following error for my attachent:
E/Gmail(11511): java.io.FileNotFoundException: No content provider: data://text/plain;base64,
I think this means that my phone does not have a user-friendly content provider that can process uris data. So I think that we should create a ContentProvider (see http://developer.android.com/guide/topics/providers/content-provider-creating.html )
And we realize
openOutputStream(android.net.Uri)
to return the contents of uri data.
source share