Issue
I am using flutter_email_sender to compose an email using the native iOS Mail app inside my Flutter app:
import 'package:flutter_email_sender/flutter_email_sender.dart';
Future<void> sendEmail(String subject, String body) async {
final Email email = Email(
body: body,
subject: subject,
);
String platformResponse;
try {
await FlutterEmailSender.send(email);
platformResponse = 'success';
} catch (error) {
platformResponse = error.toString();
}
if (!mounted) return;
print(platformResponse);
}
However my goal is to send HTML in the body of the email. When I pass markup to String body
the email is composed but not in markup, just text.
I am aware of url_launcher but that package launches the Mail app. I want the email composed as if I was calling MFMailComposeViewController in iOS.
Solution
I found that using share one can select the standard iOS Mail app. If I pass HTML to this package, it will not launch the app separately, but will enable the user to compose the email inside the app, which is what I want:
Share.share('<html>Check out the <a href=\"https://pub.dartlang.org/packages/share\">share</a> Flutter package!</html>');
Answered By - Hahnemann Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.