unit uSmtpJsWrapper;

interface

type
    TSmtpJsWrapper = class
        class procedure Send(const ARecipient, AName, ASender, ASubject, ABody: string);
    end;

implementation

class procedure TSmtpJsWrapper.Send(const ARecipient, AName, ASender, ASubject, ABody: string);
var
    LBody: string;
begin
    LBody := AName + #10 + ABody;
    // The PAS2JS compiler flag ignores the Delphi compliler, and uses the JavaScript compiler instead
    // This allows for the code to run without errors
    {$IFDEF PAS2JS}
    asm
        Email.send({
            SecureToken : "...",
            To : ARecipient,
            From : ASender,
            Subject : ASubject,
            Body : LBody
        }).then(
            message => alert(message)
        );
    end;
    {$ENDIF}
end;
end.
