Reputation:
I have a button and a string property that holds an email address. Once the button is clicked, I want it to open up the Mac Mail/Windows Mail with the string property's email address inside the To:
How can I go about doing so? Any guidance or insight would be greatly appreciated!
Upvotes: 3
Views: 7604
Reputation: 10391
you can use window.location.href = `mailto:${this.props.email}`
class EmailButton extends Component {
constructor(props){
super(props);
this.onClick = this.onClick.bind(this);
}
onClick(){
window.location.href = `mailto:${this.props.email}`;
}
render(){
return <button onClick={this.onClick}>EmailButton</button>;
}
}
also you can use <a href={`mailto:${email}`}>EmailButton</a>
Upvotes: 10