I am trying to send an email using the `N/email` ...
# suitescript
p
I am trying to send an email using the
N/email
module but am getting an unexpected error when I try it save it. For now, I am using the sample code in SA. It does work in dev console but when I try and save it I cannot.
Copy code
/**
    *@NApiVersion 2.1
    *@NScriptType ClientScript
    */
    define(['N/email', 'N/record'], (email, record) => {
        function sendEmail(context) {
            const senderId = 48911;
            const recipientEmail = '<mailto:myemail@email.com|myemail@email.com>';
            let timeStamp = new Date().getUTCMilliseconds();
        
            let recipient = record.create({
                type: record.Type.CUSTOMER,
                isDynamic: true
            });
            recipient.setValue({
                fieldId: 'subsidiary',
                value: '2'
            });
            recipient.setValue({
                fieldId: 'companyname',
                value: 'Test Company' + timeStamp
            });
            recipient.setValue({
                fieldId: 'email',
                value: recipientEmail
            });
        
            let recipientId = recipient.save();

            email.send({
                author: senderId,
                recipients: recipientId,
                subject: 'Test Sample Email Module',
                body: 'email body'
            });
        } 
        return {
            sendEmail: sendEmail
        }
    });
b
dont use suitescript 2.1