I"ve made a bound script scanning the records of its spreadsheet and if some conditions are true a email is sent to the appropriate employee
To be more specific the script is checking whether the list of employees are having birthday or not through a column than has true of false values.My script was working for a couple of weeks and today it stopped sending emails without changing anything
my code
function send() {
//returns the current active spreadsheet
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getActiveSheet();
var recipient;
var startRow = 2; // First row of data to process
var lastRow = sheet.getLastRow();//Last row to process ,the EOF
var emailSend = "FALSE";//flag to know if the mail has been sent
var d = new Date();//saving the date
var timeStamp = d.getYear();//specifing the years section
//take images location
var wishes_imageURL ="http://dekhnews.com/wp-content/uploads/... nielsen_imageURL="http://www.nielsen.com/content/dam/nielsenglobal/us
//change them to objects blobs
var wishesBlob = UrlFetchApp
.fetch(wishes_imageURL)
.getBlob()
.setName("wishesBlob");
var nielsenBlob = UrlFetchApp
.fetch(nielsen_imageURL)
.getBlob()
.setName("nielsenBlob");
//for every employee that the 4rth column is true(has_birthday) send email to his/her email address
for (var i =startRow ; i <= lastRow; i++) {
//take info about if the birthday mail has been send before to the employee
emailSend = sheet.getRange(i, 6).getValue();
//whoever has birthday and havent get email before send him/her mail
if( ( sheet.getRange(i, 5).getValue() == true) && (emailSend !="TRUE") && ( timeStamp == sheet.getRange(1, 7).getValue())){
recipient = sheet.getRange(i, 4).getValue();
MailApp.sendEmail(sheet.getRange(i, 4).getValue(),
"",
"BirthDay Wishes",
{ htmlBody:"<h3 style='text-align:center; color:blue;'><i>" + "Για τα γενέθλιά σου ευχόμαστε ολόψυχα Χρόνια Πολλά και κάθε προσωπική και επαγγελματική επιτυχία!" +
"</i></h3>" + "<center><img src='cid:wishes' style='width:500px; height:450px; align:center; position:relative; '/></center>" + "\n" +
"<h3 style = 'text-align:center;color:blue;'>" + "Βίκη – Σπύρος &" +"\n" + "Δ/νση Ανθρώπινου Δυναμικού" + "</h3>" + "\n"
+ "\n\n\n\n"+ "<center><img src='cid:nielsen'/></center>",
inlineImages:
{
wishes: wishesBlob,
nielsen: nielsenBlob
}
});
//after we sent the mail we "lock" this emplyee for the current year
sheet.getRange(i,6).setValue("TRUE");
}
}
i check the execution transcript and it doesnt show if an email is sent.But if i use something like this it works
MailApp.sendEmail("recipient.address@gmail.com", // to
"sender.name@gmail.com", // from
"Your Subject Goes Here", // email subject
"What ever you want to say"); // email body
Can you please help me..?thanks in advance