How to send email with flutter desktop - flutter

I am currently looking for ways to send an email from flutter desktop. any one knows how I can do this?
flutter_email_sender: ^5.0.2 has support for only iOS and android .
I am building a desktop app that collects users inputs and generates a receipt pdf from it. I want to send the pdf file to my email

You can use url_launcher package to send email
final Uri params = Uri(
scheme: 'mailto',
path: 'example#gmail.com',
query: encodeQueryParameters(<String, String>{
'subject': 'Your subject goes here'
}),
);
var url = params.toString();
await launch(url);
This way it'll work in all platforms

Related

Flutter `launchUrl` redirect to PDF

I am using flutter launchUrl on android, I tested it downloading pdfs as well, works fine. But if I have a .php url which downloads a PDF I get a white screen. I could set mode: LaunchMode.externalApplication in order to switch to the downloads. Is there a way to open the file in the browser or using the default app?
Uri uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri,
mode: LaunchMode.externalApplication);
}

Cannot send SMS in Flutter Web

I am creating a web app in flutter. It is used for entering students' attendance into the database.
What I want to achieve is to send SMS to the parents of absent students. I came upon flutter_sms 2.3.1 and it is supported for Android, iOS and web as per the pub.dev docs but I could not find any reference about sending SMS in flutter web using the same package. Please let me know if there is any way to achieve this task that I want.
Following is the code for sending the SMS but not working in Flutter web.
void _sendSMS(String message, List<String> recipents) async {
String _result = await sendSMS(message: message, recipients: recipents)
.catchError((onError) {
print(onError);
});
print(_result);
}
Twilio API would totally help you sending sms/whatsapp messages from any plaform automatically

How can I share images on a S3 bucket from a Flutter Web app?

On the mobile versions of the app I am using the esys flutter share package
This is the snippet that I am using:
() async {
var request = await HttpClient()
.getUrl(Uri.parse(product.imageUrl));
var response = await request.close();
Uint8List bytes =
await consolidateHttpClientResponseBytes(response);
await Share.file(
'Text to show?', 'amlog.jpg', bytes, 'image/jpg',
text: '${product.name}\nSolo por $finalPrice');
}
Unfortunately this package doesn't support Web platform.
There is a package called share plus 2.0
On the example they say that one can share files in the following way:
Share.shareFiles(['${directory.path}/image.jpg'], text: 'Great picture');
Share.shareFiles(['${directory.path}/image1.jpg', '${directory.path}/image2.jpg']);
However, in my case the file is on S3. I need to download it to some app folder. Because my app is Web I don't know how to download the pictures and stored in a folder of the app. Is this possible? Is there another way to achieve what I want?
keep downloaded file in a variable and then push it where you need it.

How to open Gmail app (Not creating email just only open inbox) in url_launcher?

mailto:<email address>?subject=<subject>&body=<body>
This one creates an email. I want to just open the Gmail app (inbox) with url_launcher package.
Is it possible?
You can simple use
launch("https://mail.google.com/mail/u/0/#inbox")
This will open the inbox
You can use external dependency to open any app or playstore directly.
https://pub.dev/packages/external_app_launcher
Yes, it is possible with the url_launcher package.
To open the gmail app (inbox) with pre-filled mailto, subject and body, you can do something like this:
final Uri params = Uri(
scheme: 'mailto',
path: 'mailto#gmail.com',
query: 'subject=This is the subject&body=this is body',
);
final url = params.toString();
launch(url);

flutter - how to open mail/sms apps

url_launcher helps to draft an email, make a call and send a sms to a specific recipient. Is there any way to launch mail/sms apps (inbox - not draft) ?
I'm not sure if you can do that in iOS but for Android, use android_intent plugin and put the appropriate package_name in data.
if (platform.isAndroid) {
AndroidIntent intent = AndroidIntent(
action: 'action_view',
data: 'package:com.example.app',
);
await intent.launch();
}