Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native linking mail api support subject, body?

Tags:

react-native

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

like image 682
ChangJoo Park Avatar asked Mar 05 '16 14:03

ChangJoo Park


2 Answers

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

like image 163
G. Hamaide Avatar answered Sep 22 '22 11:09

G. Hamaide


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.

like image 45
chrisK Avatar answered Sep 20 '22 11:09

chrisK