Drafts Action Directory

Combined Mail

Posted by comfortablynick, Last update 5 months ago

Prompt for HTML or plain text

Install

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

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.