Attach Captured Image to Email

plugins

#1

Hello Everyone,
I have functionality in which I am able to select Image by capturing it by camera or selecting from Image Picker. I also store that Image to Gallery. Now I have one web api which sends Email which is working fine as well, now I wanted to Sent That Image as Attachment of Email. Does any one know how can I achieve that ?
I know how to attach Image to Email from web api but I don’t know how to Pass that Image to web API.

       exports.onCapture = function(args)
   { 
var dialogs = require("ui/dialogs");
dialogs.action({
  message: "Select Option to Attach Image",
  cancelButtonText: "Cancel",
  actions: ["Camera", "Gallary"]
}).then(function (result) {
  console.log("Dialog result: " + result); 
  if(result == "Camera"){
      //Do action1
      console.log("Camera selected");
      if(imagecontainer.imageSource!=null)
      {
          imagecontainer.imageSource=null;
      }
      
camera.takePicture({
  width: 200, height: 200, keepAspectRatio: false, saveToGallery: true
})   
.then(function (imageAsset) {
    console.log("Result is an image asset instance"); 
   
    imageAsset.getImageAsync(image => {
    imagecontainer.imageSource = imageSource.fromNativeSource(image);
    console .log("image source:"+image);
    });
}).catch(function (err) {
    console.log("Error -> " + err.message);
});
  }else if(result == "Gallary"){
      if(imagecontainer.imageSource!=null)
      {
          imagecontainer.imageSource=null;
      }
      //Do action2
      var items;
      var imagepicker = require("nativescript-imagepicker");
      var context = imagepicker.create({
          mode: "single"
      });
      context.authorize()
          .then(function() {
              return context.present();
          })
          .then(function(selection) {
              selection.forEach(function(selected) {
                selected.getImage({ maxWidth: 200, maxHeight: 200, aspectRatio: 'fill' })
                .then((imageSourceS) => {
                    imagecontainer.imageSource = imageSourceS;
                });
               
                console.log("pic selected");
              });
          }).catch(function (e) {
          console.log(e);
      });
  }
});
};

Above code working fine.
I want imagecontainer’s Image as attachment of my email.