emailContact( )


Sends a triggered email to the current contact, unless that contact is marked as unsubscribed.

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.

You can use this function to send an email the current site visitor only. To receive the email, the site visitor must be subscribed or marked as 'subscription not set'. If the site visitor is marked as unsubscribed, the email will not be sent. Read more about how to check the contact's subscription status.

To send an email to a subscribed contact who is not the current site visitor, use the wix-crm-backend triggeredEmails.emailContact() function.

If the specified Triggered Email contains variables, you can pass values for those variables using the optional options parameter. You pass the options object, which contains the values to replace the variables defined in your triggered email. The values passed must be strings. If the object you pass to the variables object 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 contactId 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

ID of the triggered email to send.


contactIdstringRequired

ID of the contact to send the email to.


optionsTriggeredEmailOptions

Variable values to insert into the email.

Was this helpful?
Yes
No