Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch and open email client ReactJS

I want to show a pop-up like this click here in my react application. In simple words, I want to launch and open the email client in ReactJs. I am currently using a simple p tag:

 <p className="cnct_email_addr">Email US</p>

I know there is a way to use mailto like this:

<a href="mailto:[email protected]">Email Us</a>

But I want to know if there is a more reactish-way of doing it. If there is one please let me know.

like image 551
K.SINGH Avatar asked Sep 15 '20 19:09

K.SINGH


People also ask

How do I open an email in react JS?

import { Linking } from 'react-native' React Native Open Mail <TouchableOpacity onPress={() => Linking. openURL('mailto:[email protected]')}> <Text>[email protected]</Text> </TouchableOpacity> React Native Open Mail With Subject & Body <TouchableOpacity onPress={() => Linking.

How do I use mailto In react?

React-MailTo - CodeSandbox. <Mailto email="[email protected]" subject="Hello" body="Hello world!"> Mail me! You need to enable JavaScript to run this app.

How do I open an email client in HTML?

<a href="mailto:address"> When the href attribute of the A element is set as follows, users can open the email client by clicking that link.


1 Answers

You can open the mailto link using window

window.open('mailto:[email protected]?subject=Subject&body=Body%20goes%20here')
like image 178
Hatem Avatar answered Sep 25 '22 00:09

Hatem