回答編集履歴

1

MailApp.sendEmail の引数の誤りについて追記

2021/02/18 22:16

投稿

draq
draq

スコア2573

test CHANGED
@@ -16,9 +16,19 @@
16
16
 
17
17
 
18
18
 
19
+ また `options` を引数にわたすオーバーロードとは引数の渡し方を誤っています。
20
+
21
+
22
+
19
- > sendEmail(recipient, subject, body, options)
23
+ > 1. sendEmail(recipient, subject, body, options)
20
24
 
21
25
  > [https://developers.google.com/apps-script/reference/mail/mail-app#sendemailrecipient,-subject,-body,-options](https://developers.google.com/apps-script/reference/mail/mail-app#sendemailrecipient,-subject,-body,-options)
26
+
27
+
28
+
29
+ > 2. sendEmail(message)
30
+
31
+ > [https://developers.google.com/apps-script/reference/mail/mail-app#sendemailmessage](https://developers.google.com/apps-script/reference/mail/mail-app#sendemailmessage)
22
32
 
23
33
 
24
34
 
@@ -50,14 +60,18 @@
50
60
 
51
61
 
52
62
 
53
- var options = {
63
+ //オーバーロード1なら
54
64
 
55
- attachments: images,
65
+ var options = { attachments: images };
56
66
 
57
- };
67
+ MailApp.sendEmail(to, subject, body, options);
58
68
 
59
69
 
60
70
 
71
+ //オーバーロード2なら
72
+
61
- MailApp.sendEmail({ to: to, subject: subject, body: body, options: options });
73
+ var message = { to: to, subject: subject, body: body, attachments: images };
74
+
75
+ MailApp.sendEmail(message);
62
76
 
63
77
  ```