Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
Enviar un correo electrónico en reaccionar nativo

Soy nuevo en reaccionar nativo. Tengo un área de entrada de texto en mi aplicación. Quiero enviar el texto que el usuario escribió a mi gmail. ¿Cómo puedo hacer eso?

Aquí mis códigos:

 import React, { useState } from "react" import { View, Text, TextInput } from "react-native" import ModalButton from "./ModalButton" import styles from "./theme" const StoreReview = (props) => { const [comment, setComment] = useState('') return ( <View style={styles.container}> <Text style={styles.headerText}> We are very sorry about this. Can you share your experiences? </Text> <View style={styles.commentArea}> <TextInput onChangeText={setComment} value={comment} multiline={true} /> </View> <View style={styles.button}> <ModalButton buttonText={'Send'} onPress={() => { console.log(comment, 'send that commet to gmail') }} /> </View> </View> ) } export default StoreReview

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Puede usar el módulo de vinculación con el esquema mailto para abrir la aplicación de correo.

Importar el módulo de Linking :

 import { Linking } from 'react-native';

Luego, usa su función openURL() para abrir la aplicación de correo:

 await Linking.openURL('mailto:youremail@example.com');

También puede usar la función canOpenURL() para verificar si el enlace es compatible:

 const url = 'mailto:youremail@example.com'; const supported = await Linking.canOpenURL(url); if (supported) { await Linking.openURL(url); }

Entonces, en tu ejemplo, se vería así:

 import React, { useState, useCallback } from 'react'; import { View, Text, TextInput, Linking } from 'react-native'; import ModalButton from './ModalButton'; const StoreReview = (props) => { const [comment, setComment] = useState(''); const emailAddress = 'youremail@example.com'; const url = `mailto:${emailAddress}?body=${comment}`; const handlePress = useCallback(async () => { const supported = await Linking.canOpenURL(url); if (supported) { await Linking.openURL(url); } }, [url]); return ( <View style={styles.container}> <Text style={styles.headerText}> We are very sorry about this. Can you share your experiences? </Text> <View style={styles.commentArea}> <TextInput onChangeText={setComment} value={comment} multiline={true} /> </View> <View style={styles.button}> <ModalButton buttonText="Send" onPress={handlePress} /> </View> </View> ); } export default StoreReview;

Editar: Me acabo de dar cuenta de que desea incluir el comment en el cuerpo del correo electrónico.

Para configurar el asunto y el cuerpo del correo electrónico, simplemente cambie su URL de mailto:youremail@example.com a mailto:youremail@example.com?subject=Hello&body=World .

Entonces, en tu caso, la URL debería ser:

 const [comment, setComment] = useState(''); const emailAddress = 'youremail@example.com'; const url = `mailto:${emailAddress}?body=${comment}`;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda