I've been following the instructions here to have my Gmail signature template display the image stored on Google Drive as a logo.
The goal is to have the 'src' attribute of the image tag point to the image and display it inline. In the answer linked above, the image blob is fetched using UrlFetchApp. In my code, I'm calling the openById(id) method of the DriveApp to open the image file and get the blob.
However, neither approach seems to work. It's only when I have the 'src' point directly to the image URL that it loads the image. I tried using both base64Encode and base64EncodeWebSafe but the signature only shows the empty container for the image.
What am I missing here?
HTML template
<table>
<tbody>
<tr>
<td>
<img src="{{config.imgData}}" alt="my logo">
</td>
<td>
<table>
<tbody>
<tr><td> My name is {{config.name}} </td> </tr>
<tr><td> www.example.com </td> </tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
GS code
var config = {
name: "Anton",
imgData: ""
}
function updateSignature() {
var imgFileId = "DRIVE FILE ID";
var imgFile = DriveApp.getFileById(imgFileId);
var imgBlob = imgFile.getBlob().getAs("image/png"); //getAs doesn't change anything
//Get content type and bytes
var contentType = imgBlob.getContentType();
var imgBytes = imgBlob.getBytes();
var imgData = contentType + ";base64," + Utilities.base64Encode(imgData);
config.imgData = imgData;
var alias = Gmail.Users.Settings.SendAs.get("me", myEmail);
//Get signature html as a string
var templateString = HtmlService.createHtmlOutputFromFile("signature_template").getContent();
for (var configKey in config) {
if (config.hasOwnProperty(configKey)) {
templateString = templateString.replace("{{config." + configKey + "}}", config[configKey]);
}
}
var finalTemplate = HtmlService.createHtmlOutput(templateString).getContent();
alias.signature = finalTemplate;
Gmail.Users.Settings.SendAs.update(alias, "me", myEmail);
}

If my understanding is correct, how about this answer? Please think of this as just one of several possible answers.
Issue and workaround:
When I checked the official document, I saw the image for the signature as follows.
When
data:image/png;base64,###is used forsrcof the image tag, it was found that the signature updated withGmail.Users.Settings.SendAs.update()doesn't includesrcattribute. Whenhttps://###is used, the signature updated withGmail.Users.Settings.SendAs.update()includes thesrcattribute.From above situation, it is considered that
data:image/png;base64,###might not be able to be used tosrcof the image tag of the signature. This might be the specification.So in order to put the image from Google Drive, how about the following flow? I think that this is the method showing at the official document.
Modified script:
When your script is modified, how about the following modification?
From:
To:
Note:
imgDataofvar imgData = contentType + ";base64," + Utilities.base64Encode(imgData);might beimgBytes. And when you want to put the image tosrcusing the base64 data, please usesrc="data:image/png;base64,###". In your script,src="image/png;base64,###"is used.References:
If I misunderstood your question and this was not the direction you want, I apologize.