Using the documentation in the SF Help docs I am trying to create send an email to a specific person using the following code:

<script type="text/javascript" runat="server">

try {

    Platform.Load("Core", "1.1.1");
    var time = Now();
    var systemTime = Platform.Function.SystemDateToLocalDate(time);

    var esdParams = {
        "CustomerKey": "test_send_definition",
        "Name": "test_send_definition",
        "EmailSubject": "This is the default subject"

    // local values
    var scKey = '100';
    var emailKey = 'my_test_email';
    var deKey = 'send_dataextension';
    var pubListKey = 'Test_Publication_List';

    Send.Definition.AddWithDE(esdParams, scKey, emailKey, deKey, pubListKey);

    // send the email to the send definition
    var esd = Send.Definition.Init('ssjs_sent_test_1');
    var status = esd.Send();

} catch (ex) {
  Write("failure message: " + ex ); 

However running this code returns the following error:

failure message:  Error adding EmailSendDefinition.

The 100 key is the Sender Classification, and my user initiated send references the same Send Classification, Email Template and Targeted Data Extension.

Any ideas on what could be the issue or how to debug would be appreciated.

  • Is 100 the key for your 'Default'? If so, I believe that you are looking at Sender Profile, not Send Classification. Send Classification defaults are usually 'Default Commercial' and 'Default Transactional' or similar. Nov 12, 2018 at 13:59
  • The 100 is just for this example, I use a different ID in my real script. Nov 12, 2018 at 14:55
  • Do you want to send to a DE and or an individual person? Description says "an email to a specific person". If that's the case, I'd trigger an email instead of sending to a DE. Dec 15, 2018 at 13:11

1 Answer 1


Unless you are automating the process of creating the send definition, you can create one in SFMC Interface: Email Studio > Interactions > Message > Email > User-Initiated > Create.

For your server-side javascript code, please check all the parameters.

  1. Customer key, name, and subject line for send definition

1) This sample code retrieves a send based on the specified filter criteria:

    var sendCustomerKey = "test_send_definition";
    var esd = Send.Definition.Retrieve({Property:"CustomerKey",SimpleOperator:"equals",Value:sendCustomerKey});

    if (esd.length > 0) {
        Write("####A send with the CustomerKey value (" + sendCustomerKey + ") already exists.<br>");

2) This sample code retrieves a send based on the specified filter criteria:

    var sendCustomerKey = "test_send_definition";
    var esd = Send.Definition.Retrieve({Property:"Name",SimpleOperator:"equals",Value:sendCustomerKey});

    if (esd.length > 0) {
        Write("####A send with the Name value (" + sendCustomerKey + ") already exists.<br>");

Now, check the customer keys of local values exist in SFMC.

  1. Customer key for related send classification Use the Send Classification Server-side JavaScript functions to retrieve information on the send classifications used as part of the email sends.

    var scKey = '100';
    var results = SendClassification.Retrieve({Property:"CustomerKey",SimpleOperator:"equals",scKey});
    if (results.length < 1) {
        Write("###Send Classification Not Exists");
  2. Customer key for email used in send definition This sample code retrieves an array of emails based on the specified criteria:

    var emailKey = 'my_test_email';
    var results = Email.Retrieve({Property:"CustomerKey",SimpleOperator:"equals",Value:emailKey});
    if (results.length < 1) {
        Write("###Email Not Exists");
  3. Customer key of sendable data extension used in send definition This sample code retrieves data extensions based on the specified filter criteria:

    var deKey = 'send_dataextension';
    var results = DataExtension.Retrieve({Property:"Name",SimpleOperator:"equals",Value:deKey});
    if (results.length < 1) {
        Write("###data extension do not exists");
    if (!results[0]["IsSendable"]) {
        Write("###Data extension is not sendable");
  4. Customer key of publication list to use with send definition This sample code retrieves a list based on the specified filter criteria:

    var pubListKey = 'Test_Publication_List';
    var lists = List.Retrieve({Property:"Name",SimpleOperator:"equals",Value: pubListKey});
    if (results.length < 1) {
        Write("###publication list do not exists");

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .