Чтобы отправить электронное письмо с помощью Google Script, вы можете использовать службу Gmail, предоставляемую Google Apps Script. Вот несколько методов, которые вы можете использовать:
-
Использование службы GmailApp:
function sendEmail() { var recipient = 'recipient@example.com'; var subject = 'Hello from Google Script!'; var message = 'This is the body of the email.'; GmailApp.sendEmail(recipient, subject, message); }
-
Использование службы MailApp:
function sendEmail() { var recipient = 'recipient@example.com'; var subject = 'Hello from Google Script!'; var message = 'This is the body of the email.'; MailApp.sendEmail(recipient, subject, message); }
-
Отправка электронного письма с расширенными параметрами:
function sendEmail() { var recipient = 'recipient@example.com'; var subject = 'Hello from Google Script!'; var message = 'This is the body of the email.'; var options = { cc: 'cc@example.com', bcc: 'bcc@example.com', attachments: [/* Array of file blobs or file URLs */], htmlBody: '<p>This is the HTML body of the email.</p>', }; GmailApp.sendEmail(recipient, subject, message, options); }
Не забудьте заменить 'recipient@example.com'
фактическим адресом электронной почты получателя. Вы также можете настроить тему, сообщение и другие параметры электронной почты в соответствии со своими требованиями.