Issue with sending Attached Email


#1

Hey ,
i was trying to create a csv file using Cordova Plugin file , and send it using Email Composer , unfortunately i didnt succeed to make it work !
this is my code :
File Writing part :

console.log("Start Creating file /////////");
						(<any>window).resolveLocalFileSystemURL(cordova.file.cacheDirectory, function(dir) {

							dir.getFile("file.csv", {create:true}, function(file) {
								console.log('FILE URI: ' + dir.toURL()+"file.csv");
								fileURI=dir.toURL()+"/file.csv";
								var logOb = file;        
								var log = ":: TEST FILE ::" +"\n";
								logOb.createWriter(function(fileWriter) {
									fileWriter.seek(fileWriter.length);
									var blob = new Blob([log], {type:'text/plain'});
									fileWriter.write(blob);
								}, function(e){console.error(e);});
							});
						}).catch(err => console.log(err));


						console.log("Finish Writing file");

Email Composer Part :

                     let email = {
							to: 'me@gmail.com',
							attachments: [fileURI],
							subject: "Subject",
							body: "Tatata",
							isHtml: true
						};
						this.emailComposer.open(email);


Errors :

2017-05-16 10:34:07.983915+0100 AppTech[7192:2804658] Start Creating file /////////
2017-05-16 10:34:07.988542+0100 AppTech[7192:2804658] Finish Writing file
2017-05-16 10:34:07.988634+0100 AppTech[7192:2804658] Start Email Composer /////////
2017-05-16 10:34:07.988685+0100 AppTech[7192:2804658] File in the attatchment:
2017-05-16 10:34:07.988731+0100 AppTech[7192:2804658] Start Email Composer
2017-05-16 10:34:07.991759+0100 AppTech[7192:2804658] End Email Composer
2017-05-16 10:34:07.999414+0100 AppTech[7192:2804711] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-05-16 10:34:08.000046+0100 AppTech[7192:2804711] [MC] Filtering mail sheet accounts for bundle ID: com.ionicframework.app299580, source account management: 1
2017-05-16 10:34:08.034734+0100 AppTech[7192:2804711] [MC] Result: YES
2017-05-16 10:34:08.035590+0100 AppTech[7192:2804658] [MC] Filtering mail sheet accounts for bundle ID: com.ionicframework.app299580, source account management: 1
2017-05-16 10:34:08.037174+0100 AppTech[7192:2804658] [MC] Result: YES
2017-05-16 10:34:08.089446+0100 AppTech[7192:2804658] File not found:
2017-05-16 10:34:08.099175+0100 AppTech[7192:2804658] *** Assertion failure in -[MFMailComposeInternalViewController addAttachmentData:mimeType:fileName:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/MessageUI/MessageUI-1770.3.19/Mail/MFMailComposeInternalViewController.m:744
2017-05-16 10:34:08.103901+0100 AppTech[7192:2804658] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[MFMailComposeInternalViewController addAttachmentData:mimeType:fileName:] attachment must not be nil.'
*** First throw call stack:
(0x18796afd8 0x1863cc538 0x18796aeac 0x188402710 0x19451585c 0x1001a419c 0x1001a3170 0x1001a25ac 0x100381a50 0x100381a10 0x100386b78 0x1879190c0 0x187916cdc 0x187846d94 0x1892b0074 0x18daff130 0x100017418 0x18685559c) ```


----------

My system information: :
`
Cordova CLI: 6.5.0 
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
ios-deploy version: 1.9.1 
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v6.10.2
Xcode version: Xcode 8.3.2 Build version 8E2002`
Please Help !

#2

Anyone can help??? please !