Android Question [Solved] Intent SENDTO don't work correctly with Gmail app

asales

Well-Known Member
Licensed User
I used the code below to create an e-mail with subject and body and select only the e-mail apps to send the message.
It works fine... until now.
The Gmail app don't include the subject and body text anymore.
I tried with the default mail app of the device and works.
B4X:
Dim intent1 As Intent
intent1.Initialize("android.intent.action.SENDTO", "mailto:mymail@server.com")
intent1.putExtra("android.intent.extra.SUBJECT", "Subject of the e-mail")
intent1.putExtra("android.intent.extra.TEXT", "Body/content of the e-mail")
StartActivity(intent1)
Any sugestion to fix this problem with Gmail app?

Or select only the e-mails apps using the intent ACTION_SEND?

Thanks in advance.
 

JohnC

Well-Known Member
Licensed User
This is the official doc for intents - just click "Email" on the right side.

 

asales

Well-Known Member
Licensed User
This is the official doc for intents - just click "Email" on the right side.

Thanks.
I checked this link before post the question (tested with several combinations), but I couldn't make it work with the Gmail.

I'll start a new thread to get an answer to use "intent.ACTION_SEND".
This parameter passes the subject and body, but show several apps to share, not only the mail apps.
 

JohnC

Well-Known Member
Licensed User
The reason why I sent you the link is because your intent is not fully following the guidelines on that page on how to send an email intent:

- Your intent is not specifying the To: address in the suggested way
- Your intent is not specifying a MIME type as suggested

Did you try the exact suggested way on that page to send an email intent?
 
Last edited:

asales

Well-Known Member
Licensed User
Solved with this code:
 

JohnC

Well-Known Member
Licensed User
Yes, that would make sense because the android docs I sent you said:

If you want to ensure that your intent is handled only by an email app (and not other text messaging or social apps), then use the ACTION_SENDTO action and include the "mailto:" data scheme.

Which Erel's code does:
B4X:
in.Initialize("android.intent.action.SENDTO", "mailto:")

And to place the recipient addresses in:

Intent.EXTRA_EMAIL
A string array of all "To" recipient email addresses.


Which Erel's code also does:
B4X:
in.PutExtra("android.intent.extra.EMAIL", Array As String("email@example.com"))
 
Top