Q:

Send Emails with or without Inline images depending on value in cell

Good afternoon.  I'm using the code below to send emails with inline images retrieved by ID from a cell in spreadsheet.  However, if the cell with the inline image ID is blank, the script does not send the message. 
Is there a way to tweak this code to make it work in both cases? ( with and without an ID value in cell)
Thanks

  var ss = SpreadsheetApp.getActive().getSheetByName('SendMail')
  var lr = ss.getLastRow();

  var quotaLeft = MailApp.getRemainingDailyQuota();
  //Logger.log(quotaLeft);

  if((lr-1) > quotaLeft) {
     Browser.msgBox("You have " + quotaLeft + " left and you're trying to send " + (lr-1) + " emails.  Emails were not send."); 
  } else {

    for (var i = 2;i<=lr;i++){

      var currentEmail = ss.getRange(i, 1).getValue();
      var currentSubject = ss.getRange(i, 2).getValue();
      var templateText = ss.getRange(i, 3).getValue();
      var currentname = ss.getRange(i, 4).getValue();
      var reply = ss.getRange(i, 5).getValue();

      Logger.log("Cell: " + ss.getRange(i, 6).getA1Notation());
      Logger.log("Image: "+ DriveApp.getFileById(ss.getRange(i, 6).getValue()));

      var image = DriveApp.getFileById(ss.getRange(i, 6).getValue()).getBlob();

      var message = templateText.replace("{name}",currentname);
      message += "<br/><br/><img src=\"cid:sampleImage\">";

      MailApp.sendEmail({

        to: currentEmail,
        replyTo: reply,
        subject: currentSubject,
        htmlBody: message,
        inlineImages: {sampleImage: image},    
      });

    } //close for loop

  } //close else statement

} //close sendEmails```

A:

This should do it. 
The changes will also catch and an error that may occur if the image ID is incorrect or the file format is incorrect. 
  function sendMail(){

  var ss = SpreadsheetApp.getActive().getSheetByName('SendMail')
  var lr = ss.getLastRow();

  var quotaLeft = MailApp.getRemainingDailyQuota();
  //Logger.log(quotaLeft);

   if((lr-1) > quotaLeft) {
     Browser.msgBox("You have " + quotaLeft + " left and you're trying to send " + 
    (lr-1) + " emails.  Emails were not send."); 
   } else {

    for (var i = 2;i<=lr;i++){

  var currentEmail = ss.getRange(i, 1).getValue();
  var currentSubject = ss.getRange(i, 2).getValue();
  var templateText = ss.getRange(i, 3).getValue();
  var currentname = ss.getRange(i, 4).getValue();
  var reply = ss.getRange(i, 5).getValue();
  var imageFile = ss.getRange(i, 6).getValue();
  var image = ""
   Logger.log("Cell: " + ss.getRange(i, 6).getA1Notation());
   Logger.log("Image: "+ DriveApp.getFileById(ss.getRange(i, 6).getValue()));

    if(imageFile){
     try{
    image = DriveApp.getFileById(imageFile).getBlob();
      } catch (e) {
   templateText += "<p>Image merge failed: " + e;         
   }
  }

  var message = templateText.replace("{name}",currentname);
  message += "<br/><br/><img src=\"cid:sampleImage\">";

  if(image){
  MailApp.sendEmail({
    to: currentEmail,
    replyTo: reply,
    subject: currentSubject,
    htmlBody: message,
    inlineImages: {sampleImage: image},    
  });

    } else {

  MailApp.sendEmail({
    to: currentEmail,
    replyTo: reply,
    subject: currentSubject,
    htmlBody: message,  
  });
}

    } //close for loop

  } //close else statement

 } //close sendEmails```

