使用HTML Mailer

时间:2017-08-28 10:51:57

标签: google-apps-script

我的电子邮件脚本没有使用google sheet中的特殊字符导出数据。

Google Sheet



var REQUESTS_STATE_COLUMN = 32;
var STATE_APPROVERS_EMAILED = "EMAILED_Response Pending";
var STATE_APPROVED = "Approved";
var STATE_DENIED = "Rejected";
var EMAIL_SENT = "EMAILED_Response Pending";

function sendEmail() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = SpreadsheetApp.getActiveSheet();
  var dataRange = sheet.getRange("A2:AH2");
  var data = dataRange.getValues();
  for (var i = 0; i < data.length; ++i){
  for (i in data);
    var rowData = data[i];
    var email = rowData[2];
    var emailAddress = rowData[2];
    var submiterEmail = rowData[2];
    var ProjectName = rowData[3];
    var SrDesign = "Sr. Design Architect Services";
    var PerHourRate = rowData[6];    
    var NumberOfHours = rowData[7];
    var TotalRate = rowData[8];
    var Contact  = "Contact Centre Expert";
    var PerHourRate2 = rowData[10];
    var NumberOfHours2 = rowData[11];
    var NTotalRate2 = rowData[12];
    var NJrDesign = "Jr. Design Architect";
    var PerHourRate3 = rowData[14];
    var NumberOfHours3 = rowData[15];
    var TotalRate3 = rowData[16];
    var Outsourced = "Outsourced Technical Support Resource";
    var PerHourRate4 = rowData[18];
    var NumberOfHours4 = rowData[19];
    var TotalRate4 = rowData[20];
    var Supplier = "Supplier Management";
    var PerHourRate5 = rowData[22];
    var NumberOfHours5 = rowData[23];
    var TotalRate5 = rowData[24];
    var Project = "Project Management & Execution";
    var PerHourRate6 = rowData[26];
    var NumberOfHours6 = rowData[27];
    var TotalRate6 = rowData[28];
    var UserAccount = rowData[28];
    var GrandTotalRate = rowData[29]
    var seq = rowData[1];
    var url = ScriptApp.getService().getUrl();
    var sheet = SpreadsheetApp.openById('1sS8_GQ3EMcsXCtj_j8LKg4jywKMu_8symTAFbIkGyh4').getSheetByName("Sheet1");
    var cellval = dataRange.getCell(i+1, 1).getValue();
    var emailSent = rowData[32];
Logger.log(cellval);

 
if (emailSent != EMAIL_SENT) {  // Prevents sending duplicates

 var subject = 'Technology Charges for '+ProjectName+''; 


var html = '<p style="font-family:Verdana; fontsize=9px">Hello Recipient,<br/><br/>As per Management Directive, w.e.f. 1-Aug-017, Technology shall be charging across Businesses as per following broad categories.<br/><br/>(1)  <b>Technology Design Services –</b> Charges towards time spent for Technology designing, Proof Of Concept, Testing, Product Evaluation & Finalisation<br/><br/>(2)   <b> Procurement Services –</b> Charges towards time spent for Negotiations and Closing Commercial deal with selected vendor / partner / OEM<br/><br/>(3)  <b> Project Implementation –</b> Charges towards time spent for Project Execution & Handover to Operations.<br/><br/>(4)   <b> Operations Support Services –</b> Charges towards managing day to day Operations<br/><br/>For the (Project Name / Relevant Services Name as requested by Business) under discussion, following are applicable charges.<br/><br/></p><table border="1"  cellpadding="5" cellspacing="0" style="font-family:Verdana; fontsize=9px"><tbody><tr><td style="background-color:#B8B8B1;">Sr.No.</td><td style="background-color:#B8B8B1;">Cost Element</td><td style="background-color:#B8B8B1;">Unit Price</td><td style="background-color:#B8B8B1;">UOM'+'</td><td style="background-color:#B8B8B1;">Quantity</td><td style="background-color:#B8B8B1;">Total Cost</td></tr><tr><td>1</td><td>Sr. Design Architect Services</td><td>' +PerHourRate+ '</td><td>Hrs </td><td>' +NumberOfHours+ '</td><td>'+TotalRate+'</td></tr></tr><td>2</td><td>Jr. Design Architect</td><td>' +PerHourRate3+ '</td><td>Hrs </td><td> '+NumberOfHours3+'</td><td>'+TotalRate3+'</td><tr></tr><td>3</td><td>Contact Centre Expert</td><td>' +PerHourRate2+ '</td><td>Hrs </td><td>' +NumberOfHours2+ '</td><td>' +NTotalRate2+ '</td><tr></tr><td>4</td><td>Outsourced Technical Support Resource</td><td>' +PerHourRate4+ '</td><td>Hrs </td><td>' +NumberOfHours4+ '</td><td>' +TotalRate4+ '</td><tr></tr><td>5</td><td>Supplier Management</td><td>' +PerHourRate5+ '</td><td>Hrs </td><td>' +NumberOfHours5+ '</td><td>' +TotalRate5+ '</td><tr></tr><td>6</td><td>Project Management & Execution</td><td>' +PerHourRate6+ '</td><td>Hrs </td><td>' +NumberOfHours6+ '</td><td>' +TotalRate6+ '</td></tbody></table><br><br/><b>(2)  Procurement Services:</b><table border="1"  cellpadding="5" cellspacing="0" style="font-family:Verdana; fontsize=9px"><tbody><tr><td style="background-color:#B8B8B1;">Sr.No.</td><td style="background-color:#B8B8B1;">Cost Element</td><td style="background-color:#B8B8B1;">Unit Price</td><td style="background-color:#B8B8B1;">UOM'+
'</td><td style="background-color:#B8B8B1;">Quantity</td><td style="background-color:#B8B8B1;">Total Cost</td><td style="background-color:#B8B8B1;">Tentative Time</td><tr></tr><td>1</td><td>Supplier Management</td><td>' +PerHourRate5+ '</td><td>Hrs </td><td>' +NumberOfHours5+ '</td><td>' +TotalRate5+ '</td><td></td><tr></tr><td></td><td></td><td></td><td></td><td>Total</td><td>' +GrandTotalRate+ '</td><td></td></tbody></table><br><br/><b>(3)  Project Implementation Services:</b><table border="1"  cellpadding="5" cellspacing="0" style="font-family:Verdana; fontsize=9px"><tbody><tr><td style="background-color:#B8B8B1;">Sr.No.</td><td style="background-color:#B8B8B1;">Cost Element</td><td style="background-color:#B8B8B1;">Unit Price</td><td style="background-color:#B8B8B1;">UOM</td><td style="background-color:#B8B8B1;">Quantity</td><td style="background-color:#B8B8B1;">Total Cost</td><td style="background-color:#B8B8B1;">Tentative Time</td><tr></tr><td>1</td><td>Project Management & Execution</td><td>' +PerHourRate6+ '</td><td>Hrs </td><td>' +NumberOfHours6+ '</td><td>' +TotalRate6+ '</td><td></td><tr></tr><td></td><td></td><td></td><td></td><td>Total</td><td>' +GrandTotalRate+ '</td></tbody></table><br><br/><b>(4)  Operations Support Services:</b><br/>Operational Support Charges will be based on various services consumed by your business as per Technology Rate Card which will be soon shared with Business.<br><br/><b>(5)  Summary of Applicable Charges:</b><table border="1"  cellpadding="5" cellspacing="0" style="font-family:Verdana; fontsize=9px"><tbody><tr><td style="background-color:#B8B8B1;">Sr.No.</td><td style="background-color:#B8B8B1;">Cost Element</td><td style="background-color:#B8B8B1;">Total Cost</td><tr></tr><td>1</td><td>Technology Design Services</td><td></td><tr></tr><td>2</td><td>Procurement Services</td><td></td><tr></tr><td>3</td><td>Project Implementation Services</td><td></td><tr></tr><td></td><td>Total Charges:</td><td></td></tbody></table><br><i><br/>Terms & Conditions:<br/><br/>(1)   All Prices are in INR<br/><br/>(2)   Charges are exclusive of applicable Taxes<br/><br/>(3)   Man-hour assumed are tentative, final charges will be basis on actual consumption.<br/><br/>(4)   Technology Capex investment for your requirement is not part of above Charges and costs for the same will be shared with you after completion of commercial negotiations.<br/><br/>(5)   Technology will start working on your requirement only after above charges are approved by you.<br/><br/>(6)   Time frame provided is basis resource availability with Technology.<br/></i><br/>You are kindly requested to approve above Total Charges for us to proceed further.<br/>No: '+cellval+'<br><br/>'
MailApp.sendEmail({
    to: emailAddress,
    subject: subject,
    htmlBody: html,
  });
    
   //Add a state in the form spreadsheet with APPROVERS_EMAILED state  
  var sheet = SpreadsheetApp.getActiveSheet();
  var lastRow = sheet.getLastRow();
  sheet.getRange(lastRow, REQUESTS_STATE_COLUMN+1).setValue(STATE_APPROVERS_EMAILED);

}
}

}
&#13;
&#13;
&#13;

我有印度格式的数字,但是,电子邮件示例1,00,000但是当脚本生成电子邮件时它排除了Cooma并且它以简单的数字格式发送100000

我使用过utf-8符号,但仍无法找到修复

1 个答案:

答案 0 :(得分:0)

您只需使用getDisplayValues而不是getValues来保留电子表格的格式。替换以下行

var data = dataRange.getDisplayValues();