I have an example of sending emails using email composer. At the moment I send emails to a user, but I would like to know how to send the same email to an array of contacts.
below I share my code:
app.js
.controller('General', function($scope){
$scope.EnvioMail= function() {
$scope.contactos=[{correo:"[email protected]"},{correo:"[email protected]"},{correo:"[email protected]"},{correo:"[email protected]"}];
for(var i=0; i<$scope.contactos.length;i++){
alert($scope.contactos[i].correo);
}
$scope.nombre="[email protected]";
if(window.plugins && window.plugins.emailComposer) {
window.plugins.emailComposer.showEmailComposerWithCallback(function(result) {
alert("Response ->");
},
"Esta es una prueba para enviar mails desde tu aplicacion ionic", // Subject
"", // Body
[$scope.nombre], // To EN ESTA PARTE QUIERO ENVIARLE A $scope.contactos[i].correo
null, // CC
null, // BCC
false, // isHTML
null, // Attachments
null); // Attachment Data
}
}
})
index.html
<ion-content ng-controller='General'>
<br><br>
<button class="button button-assertive" ng-click="EnvioMail()">enviar mail</button>
</ion-content>
In itself, what I want is to send said mail to$scope.contactos[i].correo
Create an array with only the emails. You can use the map() function for this:
So, mailList will be:
As a general rule, the ideal would be for data protection and privacy reasons for an email recipient not to see who else the email was sent to (unless it is between co-workers, friends, etc.).
Therefore, what I usually do is send the mail to the same account that sends it, and add the recipient addresses in BCC (the rest of the hidden senders):