I have a doubt regarding the setInterval function. I am trying to read the JSON file and send email to all the email id's within that JSON,But the problem is only the last email id pass to the sendtheMail() function. Therefore email send only to the last email id. below you can see my code , Please can anyone help me with this issue
async function mailSend(callback) {
for (let scriptData of automatedScriptData.dataList) {
var userData = {
email: scriptData["Business Email"],
password: "acc0unt@123",
name: scriptData["First Name"] + " " + scriptData["Last Name"],
firstName:scriptData["First Name"],
title: scriptData["Title"],
timeZone: scriptData["Time Zone"],
location: scriptData["Country"],
company: scriptData["Company"]
};
setInterval(function() {
console.log(userData.email);
sendtheMail(userData);
}, 5*1000);
}
}