React native linking mail api support subject, body?
Asked Answered
B

2

32

Hello I use Linking api to open mailto.

I try to call mail app using below

Linking.openURL('mailto://[email protected]&subject=abcdefg&body=body')

but It will open maill app with to:[email protected]&subject=abcdefg&body=body

subject and body are empty

Bodleian answered 5/3, 2016 at 14:51 Comment(0)
C
60

You need to remove the '//' in your url and add a '?' : mailto:[email protected]?subject=abcdefg&body=body

Cohbath answered 5/3, 2016 at 15:3 Comment(6)
it just fill email adressBodleian
Check thisCohbath
Works fine on my device. Are you on Android ? Have you changed the url with the '?' as per my example ?Cohbath
how to send a link using email?Overthecounter
how to simply open mail inbox ?Estuarine
Tip: If you want to use spaces in your subject or body you need to wrap your message in encodeURIComponent to replace the space to %20 e.g. mailto:[email protected]?subject=${encodeURIComponent("This is a subject")} github.com/facebook/react-native/issues/…Proffer
D
4

Here are my cases:

  • SMS link:

return (Platform.OS === 'android') ? sms:1-408-555-1212?body=yourMessage : sms:1-408-555-1212&body=yourMessage;

  • Mail link:

return (Platform.OS === 'android') ? mailto:[email protected]?cc=?subject=yourSubject&body=yourMessage : mailto:[email protected]?cc=&subject=yourSubject&body=yourMessage;

Note: your mail url must contain cc= even if you don't have any cc emails.

  • iOS: you use ?
  • android: you use &

for the first parameter.

Diagnostic answered 22/3, 2018 at 4:30 Comment(2)
Did you intend to say, iOS use '&' and Android '?' before 'subject='. developer.apple.com/library/archive/featuredarticles/…Mantellone
@EdoftheMountain Before body (SMS) and subject (Mail link). Really sorry for the late reply.Diagnostic

© 2022 - 2024 — McMap. All rights reserved.