我正在使用 url_launcher 在我的应用程序中使用系统电子邮件发送电子邮件。我正在使用下面的代码,这个人做得很好。
void launchEmailSubmission() async {
final Uri params = Uri(
scheme: 'mailto',
path: '[email protected] /cdn-cgi/l/email-protection',
);
String url = params.toString();
if (await canLaunch(url)) {
await launch(url);
} else {
print('Could not launch $url');
}
}
但现在我想在邮件正文框中给它“默认”主题和提示文本(如果提示文本不可能,则为普通文本)。
有什么办法可以做到这一点吗?
尝试使用queryParameters
in Uri
。您可以通过以下方式实现此目的:
void launchEmailSubmission() async {
final Uri params = Uri(
scheme: 'mailto',
path: '[email protected] /cdn-cgi/l/email-protection',
queryParameters: {
'subject': 'Default Subject',
'body': 'Default body'
}
);
String url = params.toString();
if (await canLaunch(url)) {
await launch(url);
} else {
print('Could not launch $url');
}
}
它将打开默认的正文和主题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)