Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

Commit 7e6d06a

Browse files
committed
Fix outlook send with attachments
chirag04#65
1 parent 68c5cc0 commit 7e6d06a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

android/src/main/java/com/chirag/RNMail/RNMailModule.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ private String[] readableArrayToStringArray(ReadableArray r) {
5555

5656
@ReactMethod
5757
public void mail(ReadableMap options, Callback callback) {
58-
Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
59-
//i.setData(Uri.parse("mailto:"));
60-
i.setType("text/plain");
58+
Intent i;
59+
60+
if (options.hasKey("attachments") && !options.isNull("attachments")) {
61+
i = new Intent(Intent.ACTION_SEND_MULTIPLE);
62+
i.setType("vnd.android.cursor.dir/email");
63+
} else {
64+
i = new Intent(Intent.ACTION_SENDTO);
65+
i.setData(Uri.parse("mailto:"));
66+
}
6167

6268
if (options.hasKey("subject") && !options.isNull("subject")) {
6369
i.putExtra(Intent.EXTRA_SUBJECT, options.getString("subject"));
@@ -66,7 +72,7 @@ public void mail(ReadableMap options, Callback callback) {
6672
if (options.hasKey("body") && !options.isNull("body")) {
6773
String body = options.getString("body");
6874
if (options.hasKey("isHTML") && options.getBoolean("isHTML")) {
69-
i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
75+
i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body).toString());
7076
} else {
7177
i.putExtra(Intent.EXTRA_TEXT, body);
7278
}

0 commit comments

Comments
 (0)