Open Terminal & navigate to your project directory.
Add dependencies by running following command.
flutter pub add flutter_email_sender
flutter pub add url_launcher
Step 3
asyncfinal Email email = Email(
body: 'I want to send email and This is where I add email body',
subject: 'Email subject goes here',
recipients: ['[email protected]'],
isHTML: false,
);
try {
// this will open native email composer
await FlutterEmailSender.send(email);
} catch (e) {
// upon failure (if no email configured)
// we'll try to launch email composer with URL scheme
var data = Uri.encodeFull(
"subject=Email subject goes here&body=I want to send email and This is where I add email body");
var url =
Uri.parse('mailto:[email protected]?$data');
launchUrl(url);
log('Something went wrong ${e.toString()}');
}
AndroidManifest.xml file.<manifest package="com.mycompany.myapp">
<queries>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
</intent>
</queries>
</manifest>
That's it. You're all set.
Hope that, above details were helpful to you.
Cheers
Have a good one
---
Posted from 3Speak iOS App for 3Speak
Developed and maintained by @sagarkothari88