エラーが出てしまって困っています。ご教授お願いします。
内容です。
sheet.getRange(lastRow,1,array2d.length,array2d[0].length).setValues(array2d);
を上手く表現できなくてエラーが出てしまいます。
エラーメッセージは
Exception: The number of columns in the data does not match the number of columns in the range. The data has 1 but the range has 2.
とレンジの大きさのエラーが出てしまいます。データの大きさで最終行、列を指定しているつもりなのですが...
素人すぎる質問ですみません。
以下GAS内容
function myFunction() {
// 検索条件に該当するスレッド一覧を取得
var threads = GmailApp.search('subject:あああああ -label:処理済み');
// スレッドを一つずつ取り出す
threads.forEach(function(thread) {
// スレッド内のメール一覧を取得
var messages = thread.getMessages();
// メールを一つずつ取り出す messages.forEach(function(message) { // メール本文を取得 var plainBody = message.getPlainBody(); let array2d = plainBody.split('\n').map(line => line.split(',')); // 書き込むシートを取得 var sheet = SpreadsheetApp.getActive().getSheetByName('受信ナンバー'); // 最終行を取得 var lastRow = sheet.getLastRow() +1; // セルを取得して値を転記 sheet.getRange(lastRow,1,array2d.length,array2d[0].length).setValues(array2d); }); // スレッドに処理済みラベルを付ける //var label = GmailApp.getUserLabelByName('処理済み'); //thread.addLabel(label);
});
}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/01/29 06:55
退会済みユーザー
2022/01/29 07:00
2022/01/29 10:54