Using the script below on a Google Doc, I'm trying to send the document as HTML in an email body. It's converting the document correctly (when I check the exported document via the url) and sending the email with the same content, but it loses the following formatting at some point: font format (e.g., size, color) and table format (e.g., borders, background color)
function sendGoogleDocAsHTML(){
var id = DocumentApp.getActiveDocument().getId() ;
var url = "https://docs.google.com/document/d/"+id+"/export?format=html"
var param = {
method : "get",
headers : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
muteHttpExceptions:true,
};
var html = UrlFetchApp.fetch(url, param);
var email = <EMAIL>;
var subject = <SUBJECT>;
GmailApp.sendEmail(email, subject,"", {htmlBody:html});
}
How do I preserve the format in the email?