I have a scenario where I need to schedule an email at particular time every-day but the content of an email is present in some google doc and update on timely bases. So currently I am manually sending email and paste those content into my email but I want to automate the same.
So by doing search I found, it can be possible via google apps-script and I have written some script as below :
var id = '<my_Id>';
var url = "https://docs.google.com/feeds/download/documents/export/Export?id="+id+"&exportFormat=html";
var param = {
method : "get",
headers : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
contentType: "text/html",
muteHttpExceptions:true,
};
var html = UrlFetchApp.fetch(url,param).getContentText();
MailApp.sendEmail(email, 'DSR', 'html only', {htmlBody:html});
Script is working fine and I can see the contents into email but the google doc has some formatting like back-ground, foreground color, table but in email it is shows as only plain text.
Thanks.