Hi everyone, since the new updates of iOS, it is possibile to set a default mail client, different from the "Mail" app from Apple.
I always used the mailcomposer to do this task. But many people (me included) uninstalled "Mail", ans setted another client.
Mailcomposer in this case will not work anymore, will fail the initialization because there is not "Mail" installed....
How can i open always the default mail client?
This is my code:
SendMail does not work anymore, the mailcomposer is not initializing
Using "mailto:" method instead ask me to download "Mail" again :/
Thanks in advance
I always used the mailcomposer to do this task. But many people (me included) uninstalled "Mail", ans setted another client.
Mailcomposer in this case will not work anymore, will fail the initialization because there is not "Mail" installed....
How can i open always the default mail client?
This is my code:
B4X:
Sub btnRichiedi_Click
Msgbox2("Msg", "Msg", "Title", Array ("Ok"))
Wait For Msg_Click (ButtonText As String)
If ButtonText = "Ok" Then
Dim email As String = "[email protected]"
Dim subject As String = "Subject"
Dim body As String = ""
Dim su As StringUtils
Dim url As String = $"mailto:?to=${email}&subject=${su.EncodeUrl(subject, "utf8")}&body=${su.EncodeUrl(body, "utf8")}"$
If Main.App.CanOpenURL("mailto:") Then
Main.App.OpenURL(url)
Else
SendMail
End If
End If
End Sub
Private Sub SendMail
'always dim and initialize the MailComposer before you use it
Dim mailcomp As MailComposer
If mailcomp.IsInitialized Then
mailcomp.SetToRecipients(Array("[email protected]"))
mailcomp.SetSubject("Subject")
mailcomp.SetBody("Body", True)
mailcomp.Show(LockPg)
Else
Msgbox("Probabilmente non hai installata l'app 'Mail' e non hai configuarato una casella di posta.", "Errore apertura eMail")
End If
End Sub
Using "mailto:" method instead ask me to download "Mail" again :/
Thanks in advance
Last edited: