I have a simple script to read a google sheet for email addresses, send a message and if necessary send with an attachment. My code is working if all cell have data, but I want to check if the "Attachment" cell has info or not. What is the correct "If/else" syntax to add?
I've tried IF attachment == "", IF attachment == '', IF attachment.isblank(), IF attachment = Null and keep getting syntax errors.
Sorry for such a simple issue.Thank you
const attachment=sheet2.getRange(3,3).getValue(); //file id of attachmentif attachment = WHAT??? { //send without attachment MailApp.sendEmail(emailAddress,subject,emailBody,{replyTo:contact}); else //send with attachment const file = DriveApp.getFileById(attachment); //retrieve attachment and send as pdf MailApp.sendEmail(emailAddress,subject,emailBody, {replyTo:contact, attachments: [file.getAs(MimeType.PDF)]});}