Action

Combined Mail

Posted by comfortablynick, Last update over 6 years ago

Prompt for HTML or plain text

Steps

  • script

    (() => {
        const 
            opts = ['Plain Text', 'HTML'],
            p = opts.reduce(
                (prompt, buttonName) => {
                    prompt.addButton(buttonName);
                    return prompt;
                },
                Object.assign(
                    Prompt.create(), {
                        title: 'Mail',
                        message: 'Choose format to send mail',
                        isCancellable: true
                    }
                )
            ),
            choice = p.show(),
            html = p.buttonPressed == 'HTML' ? true : false,
            body = html ? draft.processTemplate('%%[[body]]%%'): draft.processTemplate('[[body]]'),
            mail = Object.assign(Mail.create(), {
              subject: draft.title,
                body: body,
              isBodyHTML: html
            }),
            success = mail.send();
        if (!success) {
          console.log(mail.status);
          context.fail();
        }
    })()

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.