2017-06-08 13 views
0

これはこれまでのコードです。 メールの最後には、私が無料で見つけたソーシャルアイコンを提供したいと思います。そして、私はそれを対応するリンクに導く。スカイプをマイナスします。ソーシャルメディアアイコンをコードに追加するにはどうすればよいですか?

https://codepen.io/anon/pen/QgjeXw

function sendEmails() { 
    var allData,counter,emailAddress,fourRowsOfData,i,lastRow, 
     message,messageStart,messageEnd,numRows, 
     row,sheet,startRow,studentName,subject; 

    //USER INPUT 
    startRow = 2; // First row of data to process 
    numRows = 4; // Number of rows to process 
    subject = "Camp Pursuit: Report Card "; 
    messageStart = "Dear Parents,"+'\n' +'\n' + 
    "Every week at Camp Pursuit, we ask the teachers to make observations about how the kiddos did." +'\n' + 
    "We know that one week isn't enough to truly know a child, so we call this our " +"Glows, Grows, & Apropos." +'\n' + 
    "Meaning..." + '\n' +'\n' + 
    "Glows: Positive things the teacher noticed" +'\n' + 
    "Grows: Areas for continued growth" +'\n' + 
    "Apropos: Ways to continue your son/daughter's enrichment" +'\n' + 
    "We hope you appreciate seeing what the teachers saw last week, and perhaps you can use some of"+'\n' + 
    "the recommendations for further enrichment this summer. Feel free to let us know your thoughts on the camp through our anonymous online survey."+'\n' + 
    "Your feedback helps us improve the experience for all kiddos! "+'\n' + 
"Survey Link: https://docs.google.com/forms/d/1g4LvA9a8sdKECr1yvp5uOoPnvKACFm3HvbTBfvQGRyo/viewform?usp=send_form" +'\n' + 
"We look forward to seeing your child at our programs throughout the year!" +'\n' + 
"Sincerely, "+'\n' + 
"The Camp Pursuit Team" 
+'\n'; 
    //END USER INPUT 

    sheet = SpreadsheetApp.getActiveSheet(); 
    lastRow = sheet.getLastRow(); 

    allData = sheet.getRange(startRow, 1, lastRow-startRow, 10);// Get All data first 

    counter = 0; 

    while (counter < lastRow-startRow) { 
    Logger.log('counter: ' + counter) 

    fourRowsOfData = sheet.getRange(startRow + counter, 1, numRows, 6).getValues(); 
    emailAddress = fourRowsOfData[0][0]; // First column of first row 
    Logger.log('emailAddress: ' + emailAddress) 

    studentName = fourRowsOfData[0][1]; 

    messageEnd = "";//Reset on every outer loop 

    for (i = 0; i < numRows; i++) {//loop numRows times - once for each row 
     row = fourRowsOfData[i]; 

     messageEnd = messageEnd + '\n' + 
      "Class: " + row[2] + '\n' +'\n' + 
       "Glows: " + row[3]+ '\n' + 
       "Grows: " + row[4] +'\n' + 
       "Apropos: " + row[5] +'\n'; 
    } 

    message = messageStart + "\n" + studentName + "\n" + messageEnd; 

    MailApp.sendEmail(emailAddress, subject, message);//Send the email outside of inner loop  
    counter+=numRows;//Increment counter by number of rows to process 
    } 
} 

答えて

0

は、私が(例えばホバー状態などを表示するために)あなたは、彼らがコードの多くを伴うようcodepenからの例を使用することができますとは思いません。ただし、ボタンを画像として保存してドライブやその他の場所に保存することもできます。

次のステップは、外部のURLから

var imageBlob = UrlFetchApp.fetch(yourImageUrl).getBlob(); 

または電子メールのHTML本文の文字列を構築する

var imageBlob = DriveApp.getFileById(yourFileId).getBlob(); 
ドライブ

からのあなたのイメージのためのブロブを取得することです。改行には 'br'タグを使用します。画像を 'a'タグで囲み、外部のウェブサイトにリンクさせる。 'img'タグの 'src'属性では、画像のblobの一意のIDを作成し、 'cid'の後ろに置いてください。

var body = "<h1> Header </h1> <br />" + 
      "<a href='www.example.com'><img src='cid:uid' /></a> Image <br />" + 
      "Content"; 

文字列パラメータの代わりに、MailApp.sendEmail()メソッドに次のオブジェクトを渡します。実行時に、スクリプトは 'body'変数に格納された文字列を解析し、cid識別子を使用してinlineImagesオブジェクトから画像を取得してhtml出力を作成します。 「inlineImages」オブジェクトのプロパティ名を使用すると、「身体」にあなたのイメージのために作成置くのIDと一致している必要があり

MailApp.sendEmail({ 
    to: "[email protected]", 
    subject: "subject", 
    htmlBody: body, 
    inlineImages: { 

     uid: imageBlob 

    } 

}); 

のhtml体を生成するために、文字列を連結しかし最善の解決策ではありません。 HtmlServiceを使用して再利用可能なhtmlテンプレートを作成することを検討してください。https://developers.google.com/apps-script/guides/html/

関連する問題