This solution is compatible with B4A, B4J and B4i.
Up until now there were two ways to send emails:
1. Using the default mobile app which required the user to actually send the message (available in B4A and B4i).
2. Using SMTP from the Net library. This required the user to enter the email account details.
Both options are problematic.
Now there is a third option which is to ask the user once for permission to send emails through his gmail account:
Once allowed we can use the Gmail API to send messages.
Start with the GoogleOAuth2 tutorial: https://www.b4x.com/android/forum/threads/class-b4x-google-oauth2.79426/#content
You need to enable Gmail API in Google developers console and get a client id.
Once you configured it correctly, it is very simple to send messages:
You can also add attachments to the email.
Up until now there were two ways to send emails:
1. Using the default mobile app which required the user to actually send the message (available in B4A and B4i).
2. Using SMTP from the Net library. This required the user to enter the email account details.
Both options are problematic.
Now there is a third option which is to ask the user once for permission to send emails through his gmail account:
Once allowed we can use the Gmail API to send messages.
Start with the GoogleOAuth2 tutorial: https://www.b4x.com/android/forum/threads/class-b4x-google-oauth2.79426/#content
You need to enable Gmail API in Google developers console and get a client id.
Once you configured it correctly, it is very simple to send messages:
B4X:
Dim msg As MailCreator
msg.Initialize
msg.HtmlBody = True
msg.ToList.Add("erel@basic4ppc.com")
msg.Subject = "test"
msg.Body = $"First line<br/>second line"$
Send(msg)
You can also add attachments to the email.