I auto-fill the To, Subject, and Body fields, and can send the email.
When I add the attachment Sub, 'ShareMultipleImages', these fields no longer auto-fill but all the attachments are listed.
I enter the To, Subject, and Body fields manually and finally send.
How can I get auto-fill and have the attachments at the same time?
B4X:
Sub savTxt_Click
' with Next line, e.To, e.Subject, and e.Body are Not auto-filled but I have Attachments.
' w/o Next line, e.To, e.Subject, and e.Body are auto-filled but No Attachments.
ShareMultipleImages(images, Starter.strSharedFolder)
Dim e As Email
e.To.Add(EditText1.text)
e.Subject = "testing23"
e.Body = "test23"
StartActivity(e.GetIntent)
' ShareMultipleImages(images, Starter.strSharedFolder)
End Sub
ps: I think I'm using the Phone library without an Intent, is this correct?
thanks in advance
Re-read the ShareFileWithFileProvider sample, updated the module and got it working with:
B4X:
Sub savTxt_Click
Log(" start savTxt")
'** Makes available Email client and Save to Drive only
Dim e As Email
e.To.Add(EditText1.text)
e.Subject = ""
e.Body = "test"
e.Attachments.Add(CreateFileProviderUri(Starter.shared, "1.txt"))
e.Attachments.Add(CreateFileProviderUri(Starter.shared, "2.txt"))
e.Attachments.Add(CreateFileProviderUri(Starter.shared, "3.txt"))
StartActivity(e.GetIntent)
End Sub
and
B4X:
Sub CreateFileProviderUri (Dir As String, FileName As String) As Object
Log("start CreateFileProviderUri")
Dim FileProvider As JavaObject
Dim context As JavaObject
context.InitializeContext
FileProvider.InitializeStatic("android.support.v4.content.FileProvider")
Dim f As JavaObject
f.InitializeNewInstance("java.io.File", Array(Dir, FileName))
Return FileProvider.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
End Sub