I'm not a pro programmer but I'm trying to attach a img file using this plugin in a mobile web app.
Now, the plugin says I have to do something like this to add an attachment
attachments:
'base64:icon.png//iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/...'
And my base64 img for example is:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJ.......
which is saved in the var imgURI
I've tried to do attachment: "base64:icon.png//" + $rootScope.imgURI.substring(24),
And also without substring or with substring 25, 26. In every case the attachment isn'ìt passed to the email composer. to:, subject:, body:, are working fine.
What am I doing wrong? Can you please help me? Thanks
you can use the imageData:
var options = {
destinationType : Camera.DestinationType.FILE_URI,
sourceType : Camera.PictureSourceType.CAMERA,
allowEdit : false,
encodingType: Camera.EncodingType.JPG,
popoverOptions: CameraPopoverOptions
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.fileURI = imageData;
}
And, in your cordova EmailComposer code you can do:
var email = {
app: 'gmail',
to: YOUR_TO,
cc: YOUR_CC,
bcc: YOUR_BCC,
attachments: [
$scope.fileURI
],
subject: YOUR_SUBJECT,
isHtml: true
};
$cordovaEmailComposer.open(email).then(null, function () {
console.log("user cancelled email");
});
It works fine for me, I can see my attached image in my Gmail's mail, for example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.