Android Question Problem with Email and AddAttachment

grafsoft

Well-Known Member
Licensed User
Longtime User
Hi,

the activity crashes when I try to add a textfile:

B4X:
    tx="....."
    tx=tx.Replace ("'",Chr (34))
   
    Dim rp As RuntimePermissions
    Dim cdir As String = rp.GetSafeDirDefaultExternal ("temp")
   
'    Added to Manifest
'    AddManifestText(<uses-permission
'    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
'    android:maxSdkVersion="18" /> )
   
    File.WriteString (cdir,"temp.csv",tx)
   
    Dim Message As Email
    Message.To.Add("[email protected]")
    Message.Subject = "Tabelle"
    Message.Body = tx
    Message.Attachments.Initialize
    Message.Attachments.Add (File.Combine (cdir,"temp.csv"))
   
    ' seems to crash here:
    StartActivity(Message.GetIntent)

' android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/b4a.mylocation/files/temp/temp.csv exposed beyond app through ClipData.Item.getUri()

Thanks in advance :)
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 1
Solution
Top