Loading
Salesforce now sends email only from verified domains. Read More
Manage Appointments with Salesforce Scheduler
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create an Apex Class for the Apex Action

          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

          Available in: Lightning Experience.
          Available in: Enterprise and Unlimited Editions
          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.

            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.

           
          Loading
          Salesforce Help | Article