Skip to content

Commit bbeafe1

Browse files
Fix sendMail
Changed the way the email intent was launched. Previously, a link was built and passed to the intent. Now, it's done the same way as the official documentation example, that can be seen [here](https://developer.android.com/guide/components/intents-common.html#ComposeEmail).
1 parent 702e422 commit bbeafe1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

android/src/main/java/com/burnweb/rnsendintent/RNSendIntentModule.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,11 @@ public void sendSms(String phoneNumberString, String body) {
322322

323323
@ReactMethod
324324
public void sendMail(String recepientString, String subject, String body) {
325-
String uriText = "mailto:" + Uri.encode(recepientString) +
326-
"?body=" + Uri.encode(body) +
327-
"&subject=" + Uri.encode(subject);
328-
329-
Intent sendIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uriText));
325+
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
326+
sendIntent.setData(Uri.parse("mailto:"));
327+
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{recepientString});
328+
sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
329+
sendIntent.putExtra(Intent.EXTRA_TEXT, body);
330330
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
331331

332332
//Check that an app exists to receive the intent

0 commit comments

Comments
 (0)