Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions android/src/main/java/com/chirag/RNMail/RNMailModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ private String[] readableArrayToStringArray(ReadableArray r) {

@ReactMethod
public void mail(ReadableMap options, Callback callback) {
Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
Intent selectorIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"));
i.setSelector(selectorIntent);
Intent i;
if (options.hasKey("attachment") && !options.isNull("attachment")) {
i = new Intent(Intent.ACTION_SEND_MULTIPLE);
Intent selectorIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"));
i.setSelector(selectorIntent);
} else {
i = new Intent(Intent.ACTION_SENDTO);
i.setData(Uri.parse("mailto:"));
}

if (options.hasKey("subject") && !options.isNull("subject")) {
i.putExtra(Intent.EXTRA_SUBJECT, options.getString("subject"));
Expand All @@ -67,7 +73,7 @@ public void mail(ReadableMap options, Callback callback) {
if (options.hasKey("body") && !options.isNull("body")) {
String body = options.getString("body");
if (options.hasKey("isHTML") && options.getBoolean("isHTML")) {
i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body).toString());
} else {
i.putExtra(Intent.EXTRA_TEXT, body);
}
Expand Down