16

Mailto appears to not be working. All that happens is that the icon appears to be pressed, but no action occurs. Shoots out this warning:

Warning

warning

Code

<TouchableHighlight onPress={() => Linking.openURL('mailto:mailto@deniseleeyohn.com?subject=abcdefg&body=body')}>
                      <Icon style={styles.icons} size={SIZE} name='envelope'/> 
    </TouchableHighlight>
user2026178
  • 308
  • 2
  • 4
  • 21

3 Answers3

18

Link not work on Simulator.

React native linking mail api support subject, body?

Apple URL Scheme Reference

Community
  • 1
  • 1
liupeixin
  • 718
  • 1
  • 9
  • 15
15

Use this code :-

Linking.openURL(`mailto:${props.ArticleData.email}`)
M H Chu
  • 428
  • 4
  • 7
ManojK
  • 171
  • 1
  • 4
3

This solution wast tested on an android emulator with a GoogleApi system image:

enter image description here

After you have the emulator configured you can use something like you are using:

<TouchableHighlight onPress={() => Linking.openURL('mailto:mailto@deniseleeyohn.com?subject=abcdefg&body=body')}>
      <Text>email1</Text>
</TouchableHighlight>

or

You can use a package like https://www.npmjs.com/package/react-native-autolink

       <AutoLink
         text="email2 (mailto:mailto@deniseleeyohn.com)"
       />
Florin Dobre
  • 9,872
  • 3
  • 59
  • 93