回答編集履歴
2
追加
test
CHANGED
@@ -18,11 +18,11 @@
|
|
18
18
|
|
19
19
|
try {
|
20
20
|
|
21
|
-
const blob = DriveApp.getFileById(file.getId()).getBlob()
|
21
|
+
const blob = DriveApp.getFileById(file.getId()).getBlob();
|
22
22
|
|
23
23
|
attached_files.push(blob);
|
24
24
|
|
25
|
-
Logger.log(file.getName() + 'を追加しました。')
|
25
|
+
Logger.log(file.getName() + 'を追加しました。');
|
26
26
|
|
27
27
|
} catch(err) {
|
28
28
|
|
@@ -47,3 +47,61 @@
|
|
47
47
|
}
|
48
48
|
|
49
49
|
```
|
50
|
+
|
51
|
+
----
|
52
|
+
|
53
|
+
アプローチ1は下記の形ではいかがでしょうか
|
54
|
+
|
55
|
+
```js
|
56
|
+
|
57
|
+
function myFunction2() {
|
58
|
+
|
59
|
+
let attached_files = [];
|
60
|
+
|
61
|
+
const attached_folder = DriveApp.getFolderById('添付用の共有フォルダのID');
|
62
|
+
|
63
|
+
const files = attached_folder.getFiles();
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
while (files.hasNext()) {
|
68
|
+
|
69
|
+
const file = files.next();
|
70
|
+
|
71
|
+
try {
|
72
|
+
|
73
|
+
const blob = DriveApp.getFileById(file.getId()).getBlob();
|
74
|
+
|
75
|
+
attached_files.push(blob);
|
76
|
+
|
77
|
+
Logger.log(file.getName() + 'を追加しました。');
|
78
|
+
|
79
|
+
} catch(err) {
|
80
|
+
|
81
|
+
Logger.log(err.toString());
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
const zipman = Utilities.zip(attached_files, 'test.zip');
|
90
|
+
|
91
|
+
// 圧縮ファイル名はメールの件名にする
|
92
|
+
|
93
|
+
const attached_zipfile = attached_folder.createFile(zipman).setName(title_text + '.zip');
|
94
|
+
|
95
|
+
const options = {
|
96
|
+
|
97
|
+
attachments: attached_zipfile,
|
98
|
+
|
99
|
+
};
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
MailApp.sendEmail('メールアドレス', '件名', '本文', options);
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
```
|
1
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
2のアプローチですが、下記ではいかがでしょうか。
|
2
2
|
|
3
|
-
```
|
3
|
+
```js
|
4
4
|
|
5
5
|
function myFunction() {
|
6
6
|
|
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
|
36
36
|
|
37
|
-
|
37
|
+
const options = {
|
38
38
|
|
39
39
|
attachments: attached_files,
|
40
40
|
|