> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: emailContact(emailId: string, contactId: string, options: TriggeredEmailOptions) # Method package: wixCrmFrontend # Method menu location: wixCrmFrontend --> TriggeredEmails --> emailContact # Method Link: https://dev.wix.com/docs/velo/apis/wix-crm-frontend/triggered-emails/email-contact.md # Method Description: Sends a triggered email to the current contact, unless that contact is marked as unsubscribed. To learn more about triggered emails, see: - [About Triggered Emails](https://support.wix.com/en/article/about-triggered-emails) - [Creating a Triggered Email](https://support.wix.com/en/article/creating-a-triggered-email) - [How to Send a Triggered Email to Contacts with Code](https://support.wix.com/en/article/how-to-send-a-triggered-email-to-contacts-with-code) Before calling `emailContact()` you need to set up at least 1 [triggered email](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/developer-tools/triggered-emails/set-up-a-triggered-email.md). This method only sends an email to the current site visitor. To receive the email, the site visitor must be a contact with a `subscriptionStatus` set to `"SUBSCRIBED"` OR `"NOT_SET"`. If the site visitor's `subscriptionStatus` is set to `"UNSUBSCRIBED"`, the email will not be sent. Read more about how to check a contact's `subscriptionStatus` ([SDK](https://dev.wix.com/docs/sdk/backend-modules/email-subscriptions/email-subscriptions/query-email-subscriptions.md) | [Velo](https://dev.wix.com/docs/velo/apis/wix-crm-backend/contacts/sort-filter-and-search.md#apis_wix-crm-backend_contacts_system-fields-supported-filters-sorting-and-search)). Currently, to send an email to a subscribed contact who is not the current site visitor is only available in Velo with the backend [`triggeredEmails.emailContact()`](https://dev.wix.com/docs/velo/apis/wix-crm-backend/triggered-emails/email-contact.md) method. If the specified triggered email contains [variables](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/developer-tools/triggered-emails/set-up-a-triggered-email.md#step-3-optional--add-variables-to-personalize-text), you can specify values for those variables using the optional `options` parameter. The values specified must be strings. If the object specified to the `variables` object does not contain a `key:value` pair for a variable in the triggered email, the fallback value defined when creating the triggered email is inserted in place of the variable. Note that creating a triggered email [generates a code snippet](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/developer-tools/triggered-emails/set-up-a-triggered-email.md#step-6--get-the-code-snippet) for each of the triggered email templates. The generated code includes the email's ID and keys for all the email's variable names. Copy and paste the snippet into your code and define values for the `contactId` property and for each variable key. To learn how to use the generated snippet in code, see [How to Send a Triggered Email with Code](https://support.wix.com/en/article/how-to-send-a-triggered-email-with-code). > **Note:** > The frontend CRM APIs aren't fully functional when previewing a site. View a published version of a site to see their complete functionality. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Send a triggered email to a contact ```javascript import { triggeredEmails } from 'wix-crm-frontend'; // ... // Sample emailId value: // 'thanks_for_joining' // // Sample contactId value: // 'e6b569cf-e275-598f-9247-e585ad116e66' triggeredEmails.emailContact(emailId, contactId) .then(() => { console.log('Email was sent to contact'); }) .catch((error) => { console.error(error); }); ``` ## Send a triggered email with variable values ```javascript import { triggeredEmails } from 'wix-crm-frontend'; // ... // Sample emailId value: // 'thanks_for_joining' // // Sample contactId value: // 'e6b569cf-e275-598f-9247-e585ad116e66' // // Sample options value: // { // variables: { // firstName: 'Johnny', // lastName: 'Appleseed' // } // } triggeredEmails.emailContact(emailId, contactId, options) .then(() => { console.log('Email was sent to contact'); }) .catch((error) => { console.error(error); }); ``` ## Send a triggered email to a new contact ```javascript import { contacts, triggeredEmails } from 'wix-crm-frontend'; $w.onReady(function () { $w('#createContact').onClick(async () => { const firstName = $w('#firstName').value; const lastName = $w('#lastName').value; const email = $w('#email').value; const phone = $w('#phone').value; const contactInfo = { name: { first: firstName, last: lastName }, emails: [{ email: email }], phones: [{ phone: phone }], }; let resolvedContact; try { resolvedContact = await contacts.appendOrCreateContact(contactInfo); console.log('Resolved to contact', resolvedContact); if (resolvedContact.identityType !== 'CONTACT') { console.log('Current contact is already a site member. Not sending a welcome email.'); // emailContact() cannot be used to email site members. // If you want to email a member, use triggeredEmails.emailMember() return; } else { const emailId = 'thanks_for_joining'; const contactId = resolvedContact.contactId; const options = { variables: { firstName: firstName, lastName: lastName }, }; await triggeredEmails.emailContact(emailId, contactId, options); console.log('Emailed contact'); } } catch (error) { console.error(error); } }); }); ``` ---