I know this is an old question, but I tried to solve this problem for a while and came up with a solution, I hope this can save someone else in the future:
from jnius import autoclass, cast from plyer.platforms.android import activity def sendemail(self, **kwargs): Intent = autoclass('android.content.Intent') AndroidString = autoclass('java.lang.String') Uri = autoclass('android.net.Uri') File = autoclass('java.io.File') intent = Intent(Intent.ACTION_SEND) intent.setType('*/*') recipient = kwargs.get('recipient') subject = kwargs.get('subject') text = kwargs.get('text') create_chooser = kwargs.get('create_chooser') file_to_attach = kwargs.get('file_to_attach') if recipient: intent.putExtra(Intent.EXTRA_EMAIL, [recipient]) if subject: android_subject = cast('java.lang.CharSequence', AndroidString(subject)) intent.putExtra(Intent.EXTRA_SUBJECT, android_subject) if text: android_text = cast('java.lang.CharSequence', AndroidString(text)) intent.putExtra(Intent.EXTRA_TEXT, android_text) if file_to_attach: attachment = File('path/to/your/file/' + file_to_attach) uri = Uri.fromFile(attachment) parcelable = cast('android.os.Parcelable', uri) intent.putExtra(Intent.EXTRA_STREAM, parcelable) if create_chooser: chooser_title = cast('java.lang.CharSequence', AndroidString('Send message with:')) activity.startActivity(Intent.createChooser(intent, chooser_title)) else: activity.startActivity(intent)
So, from the Android email section , the general intent guide shows that Intent.EXTRA_STREAM is how the application is, and after looking at the code from a similar question, here a few additional additions from this code to the Plyer email code took care of the need to get attached to the email from my application.
Significant additions were:
Uri = autoclass('android.net.Uri') File = autoclass('java.io.File')
changing intent.setType to: ('*/*') to receive files, not just text,
adding the line file_to_attach = kwargs.get('file_to_attach') to get the file from the function call,
and finally:
if file_to_attach: attachment = File('path/to/your/file/' + file_to_attach) uri = Uri.fromFile(attachment) parcelable = cast('android.os.Parcelable', uri) intent.putExtra(Intent.EXTRA_STREAM, parcelable)
to attach the file to the letter.
Then, in the function call, just include the file_to_attach argument: sendemail(recipient=' somebody@email.com ',subject='subject',text='some text',file_to_attach='a_file.csv',create_chooser=True)