Send Email with Attachments and inline images using mailgun apis


#1

I found this code, and would like to know how to play this part: :

inlines[0].data, inlines[0].filename

sendEmail(from:string, to:string, subject:string, text:string, html:string, inlines:Array):Promise {
let url = “https://api.mailgun.net/v3/” + this.domain + “/messages”;

  var headers = new Headers();
  headers.append('Authorization', "Basic " + this.apiKey);
  
  headers.append('enctype', 'multipart/form-data');
  headers.append('Accept', 'application/json');
  
  var body:FormData = new FormData();
  body.append('from', from);
  body.append('to', to);
  body.append('subject', subject);
  body.append('text', text);
  body.append('html', html);
  body.append('attachment', inlines[1].data, inlines[1].filename);
  body.append('inline', inlines[0].data, inlines[0].filename);

   let options = new RequestOptions({ headers: headers });
          
 return this.http.post(url ,body,options).map(res => res.json()).toPromise();
  
  
 
}