Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Code for Checking empty cell in AppsScript

$
0
0

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)]});}

Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>