views:

118

answers:

1

So I have som data that I have converted to a string. While I have found how to attach something from the SD-card to a mail, I cant figure out how to directly convert my string to a mail-attachment without involving the SD-card. In case it holds significance, I have read some data from a database, converted it to csv-format, and now wants to attach it as a csv-file.

Cheers,

A: 

create a temporary file using the file API's and then you can go ahead and put it as extra in the email intent like this

emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(csvFile));
the100rabh
I did try to create a file and put it in the application directory, but gmail refused to accept a file from that directory. Most likely to prevent some kind of security issue where important app-files could be stolen as email-attachment.
sandis
I save file using createTempFile(String prefix, String suffix) and it works wonderfully fine for me
the100rabh
Hi @the100rabh, can you give an example on how you made this work? Thank you!
Zarah