Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Send an email in react native

I am new at react native. I have a text input area in my app. I want to send the text that user wrote to my gmail . How can I do that?

Here my codes:

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 answers
Answer question

0

You could use the Linking module with the mailto scheme to open the mail app.

Import the Linking module:

import { Linking } from 'react-native';

Then, use its openURL() function to open the mail app:

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

You can also use the canOpenURL() function to check if the link is supported:

const url = 'mailto:youremail@example.com';

const supported = await Linking.canOpenURL(url);

if (supported) {
  await Linking.openURL(url);
}

So, in your example, that'd look like:

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;

Edit: I just realized you want to include the comment in the email's body.

To set the email subject and body, simply change your URL from mailto:youremail@example.com to mailto:youremail@example.com?subject=Hello&body=World.

So, in your case, the URL should be:

const [comment, setComment] = useState('');

const emailAddress = 'youremail@example.com';
const url = `mailto:${emailAddress}?body=${comment}`;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!