'SendAtt = map CreateMap("filename1": "path1", "filename2": "path2")
Sub SuperSendEmail (SendTo As List, SendBody As String, SendSubject As String, SendAtt As Map)
If SendTo.IsInitialized = False Then
ToastMessageShow("Email cannot be sent: empty email-address", True)
Return
End If
Dim FinalEmailIntent As Intent
Dim MyEmail As Email
MyEmail.To = SendTo
MyEmail.Body = SendBody
MyEmail.Subject = SendSubject
If SendAtt.IsInitialized Then
For i = 0 To SendAtt.Size - 1
MyEmail.Attachments.Add(CreateFileProviderUri(SendAtt.GetValueAt(i), SendAtt.GetKeyAt(i)))
Next
End If
FinalEmailIntent = MyEmail.GetIntent
FinalEmailIntent.SetType("message/rfc822") 'THE TROUBLE ROOT !!!!
FinalEmailIntent.WrapAsIntentChooser("Email:")
StartActivity (FinalEmailIntent)
End Sub
Sub CreateFileProviderUri (Dir As String, FileName As String) As Object
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