sidlatau / flutter_email_sender

Allows send emails from flutter using native platform functionality.
Apache License 2.0
151 stars 84 forks source link

Send with attachments which are not .zip #48

Open ghost opened 4 years ago

ghost commented 4 years ago

Hi and thanks for your work!

My Flutter and Dart versions are:

Flutter 1.17.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b041144f83 (3 weeks ago) • 2020-06-04 09:26:11 -0700
Engine • revision ee76268252
Tools • Dart 2.8.4

I want to send an email with a PDF/PNG/JPG as attachment(s).

My application downloads dynamically files from the internet and then I want to build a "share" button. My code is very simple:

final Email email = Email(
                      body: "Body",
                      subject: 'Subject',
                      recipients: [],
                      attachmentPaths: [path1],
                      isHTML: false,
                    );

The variable path1 is /data/user/0/com.example.project_name/app_flutter/uploads/upload.pdf. I can confirm that the file exists, since I am reading in on other places as well.

The error I receive is:

java.lang.IllegalArgumentException: Failed to find configured root that contains /data/user/0/com.example.project_name/app_flutter/uploads/upload.pdf
E/MethodChannel#flutter_email_sender( 4008):    at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:744)
E/MethodChannel#flutter_email_sender( 4008):    at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:418)
E/MethodChannel#flutter_email_sender( 4008):    at com.sidlatau.flutteremailsender.FlutterEmailSenderPlugin.sendEmail(FlutterEmailSenderPlugin.kt:102)
E/MethodChannel#flutter_email_sender( 4008):    at com.sidlatau.flutteremailsender.FlutterEmailSenderPlugin.onMethodCall(FlutterEmailSenderPlugin.kt:41)
E/MethodChannel#flutter_email_sender( 4008):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/MethodChannel#flutter_email_sender( 4008):    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#flutter_email_sender( 4008):    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
ronaldmaymone commented 4 years ago

this #10 may work for you