Android Question Sending emails with an attachment

I'm building an app where where I want to send an email (using the default mail app) with an attachment. For test purposes I'm using the code

B4X:
    Recipient = "[email protected]"
    Message.To.Add(Recipient)
    Message.Subject = "subject"
    Message.Attachments.Add(File.Combine(SaveFolder, input.Text & ".CSV"))
    StartActivity(Message.GetIntent)

When running I get an error starting with:

android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.smft.shaknspin/files/SHK2021.07.21_11%3A00%3A28.CSV exposed beyond app through ClipData.Item.getUri()

I suspect there must be some permission I must enable first ?

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0
Great, it worked!

Just a question on SharedFolder
It reports something like /data/0/user...
But I can't find that folder in the file manager.
Where is it?
 
Upvote 0
Top