Private Sub SendEmail(ToField As String, Subject As String) As Boolean
If App.CanOpenURL("mailto:") = False Then
Return False
Else
App.OpenURL($"mailto:?to=${ToField}&subject=${Subject}"$)
Return True
End If
End Sub
I'm still getting the same error. I would upload the whole project but it's massive.
Thing is, (I'm gonna use Android terminology) the activity I'm using it on, is not from the front activity... so does that make a difference?
The problem is that your subject contains spaces, and you don't encoded it.
Add the iStringUtils library to your project and use the following code:
B4X:
Sub SendEmail(Email As String,Body As String, Subject As String) As Boolean
Dim SU As StringUtils
Body = SU.EncodeUrl(Body,"UTF-8")
Subject = SU.EncodeUrl(Subject,"UTF-8")
Dim Url As String = "mailto:" & Email & "?subject=" & Subject & "&body=" & Body
If App.CanOpenURL("mailto:") = False Then
Return False
Else
App.OpenURL(Url)
Return True
End If
End Sub
Use this sub and it will work (add a reference to StringUtils):
B4X:
Private Sub SendEmail(ToField As String, Subject As String) As Boolean
If App.CanOpenURL("mailto:") = False Then
Return False
Else
Dim su As StringUtils
App.OpenURL($"mailto:?to=${ToField}&subject=${su.EncodeUrl(Subject, "utf8")}"$)
Return True
End If
End Sub