I have a sign-in form built in Google Apps Script that sends data to a row in a Google Sheet. But if a user tries to sign in that's not in a preset list, it sends an email to the clerk. The sign in computer has a webcam, and the GAS form can activate the webcam and take a picture of the person; it returns a base64 encoded string of the image data (jpeg format).
What I'm wrestling with is getting GAS to create the proper Blob to add as an inlineImage into the email.
var userImgBlob = Utilities.newBlob()
.setContentType("image/jpeg")
.setDataFromString(Utilities.base64Decode(imgTxt.slice(23)))
.setName("userImgBlob");
imgTxt contains the data: URI, coming in like:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgM....
Slicing the first 24 (0 to 23) characters removes the header so that it's just the image data. Something about this causes the script to fail, however. (Commenting this section out lets the rest of the script run fine.)
What's malformed about my definition?
NOTE: I've already looked at the How to include inline images in email using MailApp. My question's a little different, because in that post, the user was Fetching a URL from the web. This is a data: URI that I'm working with.