emailContact( )


Deprecated. This function will continue to work, but a newer version is available at wix-crm-backend.triggeredEmails.emailContact().

Sends a Triggered Email to a contact.

Migration Instructions

If this function is already in your code, it will continue to work. To stay compatible with future changes, migrate to wix-crm-backend.triggeredEmails.emailContact().

To migrate to the new function:

  1. Add the new import statement:

    Copy
    1
  2. If you plan to migrate all functions that use wixCrmBackend, remove the original import wixCrmBackend statement.

  3. Look for any code that uses wixCrmBackend.emailContact(), and replace it with triggeredEmails.emailContact(). Update your code to work with the new emailContact() call and response properties.

  4. Test your changes to make sure your code behaves as expected.

To learn more about Triggered Emails, see:

Before using the emailContact() function, you need to set up at least one Triggered Email.

Specify which email to send by passing the email's ID in the emailId parameter.

Specify which contact the email is sent to by passing a contact's ID in the toContact parameter.

If the specified Triggered Email contains variables, you can pass values for those variables using the optional options parameter. You pass a TriggeredEmailOptions object which contains the values to be inserted into your email in place of the variables defined in that email. The values passed must be strings. If the object you pass to the options parameter does not contain a key:value pair for a variable in your Triggered Email, the fallback value defined when creating your Triggered Email is inserted in place of the variable.

Note that Triggered Emails generates a code snippet for each of your email templates. The generated code includes the email's ID and keys for all the email's variable names. You can copy and paste the snippet into your code. Then, you need to define values for the toContact property and for each variable key. To learn how to use the generated snippet in your code, see How to Send a Triggered Email with Code.

Method Declaration
Copy
Method Parameters
emailIdstringRequired

The Email ID of the Triggered Email to send.


toContactstringRequired

The contact's ID you are sending the email to.


optionsTriggeredEmailOptions

Variable values to insert into the email.

Was this helpful?
Yes
No