I am working on a mail merge script that takes a draft message with GmailApp
, gets its htmlBody
and attachments, and uses these to send a new message.
It works fine with attachments, and even with inline messages that have been inserted from an outside url (including images in Gmail signature); however, it can't deal with inline images directly inserted into the draft message using the Insert image panel in Gmail: these images break.
Using the includeInlineImages
option of getAttachments()
only changes whether the inline image in question is attached to the email or not, but regardless, it is broken in the body.
Code excerpt:
var allAttachments = draft.getMessage().getAttachments()
var htmlBody = draft.getMessage().getBody()
GmailApp.sendEmail(recipient, subject, '', {
name:senderName,
from:senderEmail,
htmlBody:htmlBody,
cc:allCc,
bcc:bcc,
attachments: allAttachments
Any suggestions are appreciated.