您可以使用
mailto
打开
window
链接
window.open('mailto:[email protected]?subject=Subject&body=Body%20goes%20here')
const Mailto = ({ email, subject, body, children }) => {
return (
<a href={`mailto:${email}?subject=${encodeURIComponent(subject) || ''}&body=${encodeURIComponent(body) || ''}`}>{children}</a>
);
};
ReactDOM.render(
<Mailto email="[email protected]" subject="Hello & Welcome" body="Hello world!">
Mail me!
</Mailto>,
document.getElementById('root')
);
参考链接。
const openEmail = () => {
const recipient = "[email protected]";
const subject = encodeURIComponent("Subject Here");
const body = encodeURIComponent("Body content goes here.");
// Check if default email client exists (mailto)
try {
window.location.href = `mailto:${recipient}?subject=${subject}&body=${body}`;
} catch (e) {
// Fallback to Outlook Web App
window.open(
`https://outlook.office.com/mail/deeplink/compose?to=${recipient}&subject=${subject}&body=${body}`,
'_blank'
);
}
};
您必须导入此“链接”
<Button onPress={() => Linking.openURL('mailto:[email protected]?subject=SendMail&body=Description') }
title="[email protected]" />