Thank you for your reply.
Yes, I get this error as soon as I execute MailComposer.composeAsync - before even sending.
It displays a selection of my email applications, and when I select gmail for example, it opens gmail compose, with the title and body, but no attachment and shows the error.
can you try to use the FileSystem API or similar to inspect the contents of the files at those URLs that you are trying to attach? I think the most likely thing is that you’re not grabbing a real file to attach.
After some attempts, I managed to attach an html file to email with an iPhone - previously did not work but finally worked somehow.
However, it is still not working with my android phone. I have a bad feeling that MailComposer attachment will not work with Android… Please tell me if I am wrong.
I also looked at Share, but I cannot attach anything programmatically.
The only options left for me: A. detach my app from expo to ExpoKit. - I tried this but so far no luck.
If I can detach my app and still make it work with some email library by linking…
B. If detach and link do not work either, then I have to rebuild my app with pure react native from scratch so that I can install some email library… However, It will be shame to give up expo all together…I have spent last few months building an app with Expo…
Hi! I think I found the reason why you cannot add your file as an attachment on Android and I’ll try to find a way to fix it. It is caused by adding a file that is in documentDirectory and not cacheDirectory - if you move your file there and use the uri of the moved file it should work just fine. Of course, files in document directory should also work - I hope to fix this soon!
@aalices Thank you so much! cacheDirectory works! It is a nice surprise!
A couple of days ago I read that asyncStorage saves data specific to each app, and not accessible from other apps. So, I thought that is why email apps cannot attach (find) files from asyncStorage.
Do you still think that files in documentDirectory should also work in theory? The thing is I prefer the fact that the confidential data is not easily accessible from outside the app, but still wanting to attach a file/data from asyncStorage to an email.
Anyway, I updated my repo and snack just in case anybody else come across the same thing as me. (I will also test if I can attach an html with some image blob).
Good point. Files saved by Expo’s File System aren’t accessible for other apps by default. It requires some configuration to be able to share something with an external app. We only use this possibility for MailComposer. So, even if we let users to use documentDirectory as a root dir for files they want to share via an email, the files will still be unavailable for other apps