Posts

Showing posts from February, 2024

Send Email with Image/s in Mail Body Using GAS-2

Note: GmailApp - Respect cells formatting (line break but not bold text). MailApp - Don't respect cell formatting. It works better with HTML template.   function SendEmailUsingGAS () {   var subj = 'Test Email' ;   var mailBody = 'Test Email' ;   var img = DriveApp . getFileById ( '1fAalmjqjhjPpuDrcTBuHlt5NKCpe7Kvo' ). getAs ( 'image/png' );   var Emg ={ 'Logo' : img };   MailApp . sendEmail ({ to : 'ExcelSujeet@gmail.com' , subject : subj , htmlBody : mailBody + "<br><br>" + "<img src='cid:Logo' style='width:100px;height:100px'>" , inlineImages : Emg }); } URL's https://developers.google.com/apps-script/reference/mail/mail-app https://developers.google.com/apps-script/reference/mail/mail-app#sendemailrecipient,-subject,-body,-options Explanation This code is a Google Apps Script (GAS) function that sends an email using Gmail services and includes an inline image. Let...

Send Email with Image/s in Mail Body Using GAS-1

Note: GmailApp - Respect cells formatting (line break but not bold text). MailApp - Don't respect cell formatting. It works better with HTML template.   GS Code function DesingTeam () {   var ss = SpreadsheetApp . getActiveSpreadsheet ();   var sht_Guidelines = ss . getSheetByName ( 'Guidelines' );   var sht_DesignTeam = ss . getSheetByName ( 'Design team' );   var lastRow ;   var i ;   var strMailBody ;   var strTask ;   var strDate ;   var strTo ;   var strCC ;   //Deadline Approaching   var strMailBodyTemp_1 = sht_Guidelines . getRange ( 'D2' ). getValue ();   var strSubject_1 = sht_Guidelines . getRange ( 'C2' ). getValue ();   var image_1 = DriveApp . getFileById ( '1iQYLBJQAWn_6_0rviBuFxjyN4IMBVrJz' ). getAs ( 'image/jpeg' );   var Eimage_1 ={ 'Logo' : image_1 };   var Ebody_1 = HtmlService . createTemplateFromFile ( "DeadlineApproaching" );   var name1 ;   //Reminder ...