react-native-mail
react-native-mail copied to clipboard
Android: Support for URI and attaching files from internal storage (SOLVED)
Currently, emails cannot be attached on android unless the attachment is on an external storage. This can be resolved by:
- Using a FileProvider such as a react-native-file-provider so that internal files are exposed as contentUri
- Code changes in RNMailModule.java to check if the path is a URI or a file path
import android.webkit.URLUtil;
if (attachment.hasKey("path") && !attachment.isNull("path")) {
String path = attachment.getString("path");
Uri p;
// Check for valid URI
if (URLUtil.isValidUrl(path)) {
p = Uri.parse(path);
}
// Else this is an absolute file path
else {
File file = new File(path);
p = Uri.fromFile(file);
}
i.putExtra(Intent.EXTRA_STREAM, p);
}
I have made these changes in my fork of this repo, and I have also incorporated the pull request https://github.com/chirag04/react-native-mail/pull/42 by rusel1989
However, I can't make a pull request because I am using react-native 0.39, and the latest repo is for react-native 0.40.
If anyone needs this functionality, they are welcome to look at my fork
https://github.com/ujwal-setlur/react-native-mail
-ujwal
Thanks man, that was exactly what I needed
I have issued pull request https://github.com/chirag04/react-native-mail/pull/71
Was this ever merged?
Nope
Such a Tiny fix, @chirag04 can you please implement this. Is this even still maintained?