---
schema_version: "1"
id: 833238175522cdaab6ba1eef0479266be4ac8aa89beeb2505012fdd7eeeb3629
title: Create an Apex Class for the Apex Action
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/ls_create_apex_class_for_apex_action.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.ls_create_apex_class_for_apex_action.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: f37aa3161893d49bf4f9fc434b5e96857bcffc9bc1fdc6028e4923fdd49ae863
description: Create an Apex class that you can link to the Apex action. The email template name in the Apex class refers to the email templates that are used to send email notifications for video appointments to unauthenticated users. You can rename the template based on your setup.
products:
  - Scheduler
  - Salesforce Platform
release: "264"
---
# Create an Apex Class for the Apex Action

Create an Apex class that you can link to the Apex action. The email template name in the Apex class refers to the email templates that are used to send email notifications for video appointments to unauthenticated users. You can rename the template based on your setup.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience.</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong> and <strong>Unlimited</strong> Editions</td></tr></tbody></table>

1. Click the Setup icon, and then select **Developer Console**.
2. Click **File** | **New** | **Apex Class**.
3. Enter a name for the apex class, such as SendEmailToGuest.
4. Add the apex class code.
    
    Here’s a sample apex code for an apex class. This code is used to send email confirmation of an appointment when appointments are scheduled by using appointment types with third-party video apps.
    
    ```java
    public class SendEmailToGuest {
    
       @InvocableMethod(label='Send Email To Guest' callout='true')
    
       public static Void SendEmailToGuestUsingEmailTemplate(List<inputvariables> inputParams)
    
       {
    // Replace this unique name based on the email template used 
           EmailTemplate et = [SELECT Id,Subject, Body FROM EmailTemplate WHERE DeveloperName ='SchedulerUnauthenticatedUserAppointmentTypeEmailTemplateForThirdParty'];
           List<string> toAddress = new List<string>();
           toAddress.add(inputParams.get(0).leadEmail);
           Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    
           mail.setTemplateId(et.Id);
           mail.setToAddresses(toAddress);
           mail.setTargetObjectId(inputParams.get(0).leadId);
           mail.setWhatId(inputParams.get(0).appointmentId);
           mail.setSaveAsActivity(false);
           mail.setUseSignature(false);
           List<Messaging.SingleEmailMessage> allmsg = new List<Messaging.SingleEmailMessage>();
           allmsg.add(mail);
           try {
               Messaging.sendEmail(allmsg,false);
               return;
           } catch (Exception e) {
               System.debug(e.getMessage());
           }
       }
        
        public class inputvariables {
            @InvocableVariable
            public String leadEmail;
            @InvocableVariable
            public String leadId;
            @InvocableVariable
            public String appointmentId;
            
        } 
    }
    ```
    
    You can replace the Virtual Appointment Email template unique name based on your setup. Here are the available unique template names:
    
    SchedulerUnauthenticatedUserAppointmentTypeEmailTemplateForAmazonChime
    
    Email template for confirmation of an appointment when appointments are scheduled by using appointment types with Amazon Chime.
    
    SchedulerUnauthenticatedUserEngagementChannelEmailTemplateForAmazonChime
    
    Email template for confirmation of an appointment when appointments are scheduled by using engagement channels with Amazon Chime.
    
    SchedulerUnauthenticatedUserAppointmentTypeEmailTemplateForThirdParty
    
    Email template for confirmation of an appointment when appointments are scheduled by using appointment types with third-party video apps.
    
    SchedulerUnauthenticatedUserEngagementChannelEmailTemplateForThirdParty
    
    Email template for confirmation of an appointment when appointments are scheduled by using engagement channels with third-party video apps.
5. Save your changes.

Now, create an Apex action to send email notifications by using the Apex class.