- 用戶從打開谷歌工具欄菜單中選擇「電子郵件」。
- 它提示用戶用單選按鈕來選擇自己的領域辦公地點,並用文本區域
- 用戶點擊提交和「FFO_Email」功能添加了額外的消息在電子郵件正文運行
「FFO_Email」功能將根據無線電選擇
- 決定現場辦公地點確定電子郵件的基於現場辦公地點(「FFO-IS」 A3列表! A12)和電子郵件在右邊的「FFO-IS」片(「FFO-IS」 B3:H12)
- 創建電子郵件主題
- 創建電子郵件正文(將在側邊欄 包括從文本區域的其他消息
- 最後發送電子郵件的個人和顯示郵件已在側邊欄成功發送我有
的選擇
問題的消息無線電廣播Field Office位置和其他消息不傳遞到FFO_Email.gs函數。因此不會將電子郵件發送給個人。
表可以在這裏
FFO_email.html
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css"> <!DOCTYPE html> <html> <head> <base target="_top"> <script> function onSuccess(fieldOffice, AdditionalMessage) { var div = document.getElementById('fieldOfficeFFO'); div.innerHTML = 'Email for ' + fieldOffice + ' has been sent successfully.'; } google.script.run.withSuccessHandler(onSuccess) .FFO_Email(); </script> </head> <body> <form id=fieldOfficeFFO> <fieldset style="background-color:LightGray;width:250px"> <div> <label for="Field Office Select">Please select your field office below.</label> </div> <div> <input type="radio" name="fieldOfficeFFO" id="fieldOfficeFFO" value="ARK_E_TEXAS"> <label for="ARK_E_TEXAS">ARK_E_TEXAS</label> </div> <div> <input type="radio" name="fieldOfficeFFO" id="fieldOfficeFFO" value="BORDER_EAST"> <label for="BORDER_EAST">BORDER_EAST</label> </div> <div> <input type="radio" name="fieldOfficeFFO" id="fieldOfficeFFO" value="BORDER_WEST"> <label for="BORDER_WEST">BORDER_WEST</label> </div> <div> <input type="radio" name="fieldOfficeFFO" id="fieldOfficeFFO" value="CENTRAL_TEXAS"> <label for="CENTRAL_TEXAS">CENTRAL_TEXAS</label> </div> <div> <input type="radio" name="fieldOfficeFFO" id="fieldOfficeFFO" value="DALLAS"> <label for="DALLAS">DALLAS</label> </div> <div> <input type="radio" name="fieldOfficeFFO" id="fieldOfficeFFO" value="FORT_WORTH"> <label for="FORT_WORTH">FORT_WORTH</label> </div> <div> <input type="radio" name="fieldOfficeFFO" id="fieldOfficeFFO" value="GULF_COAST"> <label for="GULF_COAST">GULF_COAST</label> </div> <div> <input type="radio" name="fieldOfficeFFO" id="fieldOfficeFFO" value="LOUISIANA"> <label for="LOUISIANA">LOUISIANA</label> </div> <div> <input type="radio" name="fieldOfficeFFO" id="fieldOfficeFFO" value="NEW_MEXICO"> <label for="NEW_MEXICO">NEW_MEXICO</label> </div> <div> <input type="radio" name="fieldOfficeFFO" id="fieldOfficeFFO" value="OKLAHOMA"> <label for="OKLAHOMA">OKLAHOMA</label> </div> </fieldset> <br> <br> <fieldset> <div class="form-group"> <label for="AdditionalMessage">Additional Message</label> <textarea id="AdditionalMessage" rows="3" style="width:250px"></textarea> </div> </fieldset> </form> <div class="block"> <button class="blue" onclick="onSuccess(fieldOfficeFFO,AdditionalMessage)">Submit</button> <button onclick="google.script.host.close()">Close</button> </div> </body> </html>
FFO_Email.gs
function FFO_Email(fieldOfficeFFO, AdditionalMessage) { var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('FFO-IS') var firstRow = 3; var lastRow = 10; var dataRange = sheet.getRange(firstRow, 1, lastRow, 8); var myDate = new Date(); var hrs = myDate.getHours(); //Determines the row the Field Office is in for (var j = 0; j < dataRange.length; j++) { if (dataRange[j][0] == fieldOfficeFFO) { Logger.log((j + 1)) return j + 1; } } //Create the greeting based on the time of day var greeting; if (hrs < 12) greeting = 'Good Morning'; else if (hrs >= 12 && hrs <= 17) greeting = 'Good Afternoon'; else if (hrs >= 17 && hrs <= 24) greeting = 'Good Evening'; // Fetch values for each row in the Range. var data = dataRange.getValues(); for (i in data) { var row = data[i]; var field_Office = fieldOfficeFFO; var PT_Director = dataRange.getValues(j, 2); var PT_Manager = dataRange.getValues(j, 3); var PT_Management_Specialist = dataRange.getValues(j, 4); var Area_Supervisory_AM = dataRange.getValues(j, 5); var Area_AM = dataRange.getValues(j, 6); var SC_Senior_Property_Manager = dataRange.getValues(j, 7); var AMS = dataRange.getValues(j, 8); var email_Subject = field_Office + " FFO/Income Statement Report is ready for viewing"; var message_Body = greeting + "," + "<br> <br>" + "The " + field_Office + " <b>FFO/Income Statement Report is ready for viewing in</b> the <i>AMS Standard Reports - R07 Google Folder</i>" + " located at https://drive.google.com/drive/u/0/folders/0Bx1aKS2V9K-kb0tNLXFfbGtmalE" + "<br> <br>" + "<br> <br>" + //Additional Message from html side added here AdditionalMessage + "<br> <br>" + "Thank you." + "<br> <br>" + AMS; //Send email MailApp.sendEmail({ to: SC_Senior_Property_Manager + "," + Area_AM + "," + AMS, cc: PT_Director + "," + PT_Manager + "," + PT_Management_Specialist + "," + Area_Supervisory_AM, replyTo: AMS, subject: email_Subject, htmlBody: message_Body }); return fieldOfficeFFO SpreadsheetApp.flush(); Utilities.sleep(1000); } }
我通讀了您的答案並進行了更改,但仍然沒有運氣。我很好奇所選收音機和附加信息從HTML端傳遞到Google Apps腳本端 –
您需要從頭到尾調試代碼。你需要弄清楚有多少代碼正在工作,以及它停止工作的地方。除了不能工作的地方以外的一切都不可信。在最後看到最新的答案。您需要確定服務器接收數據的內容。布賴恩P是正確的'id's'。刪除所有'id =「fieldOfficeFFO」'屬性,它們是無用的。應用程序腳本將**不允許在表單對象中傳遞id,只有名稱。 –
我已經做出了您所建議的更改,並將更多內容讀入您所做的更改中。該腳本現在將電子郵件發送到個人列表,但表單並未說明電子郵件已發送。此外,我做了更多的改變,不再符合我原先發布的代碼,但仍在尋求相同的結果。我應該開始一個新問題還是應該更新我的問題? –