Email Applications – Apex Programming Language

Utilize Apex for Email Applications

When sending emails to or receiving emails from external systems in Salesforce, email programs come into play. There are two categories of emails.

  • Outbound email messaging.
  • Inbound email messaging

Outgoing email applications

Outbound email programs are used to send an email to an external system using apex. There are two types of outbound emails.

1. SingleEmailMessage: Employed for dispatching an individual email message.

Syntax

Messaging.SingleEmailMessage varEmail = new Messaging.SingleEmailMessage();
2. MassEmailMessage: This allows sending emails to a group of recipients.

Sytax

Messaging.MassEmailMessage varMemail = new Messaging.MassEmailMessage();

The Messaging namespace offers classes and methods for Salesforce outbound and inbound functionalities.

Sending Emails with Attachments

How do we send attachments? We can achieve this by utilizing EmailFileAttachment. Examples will be presented later.

Incoming email applications

This process involves receiving an email from an external system to Salesforce, where the Apex class will handle the email, attachments, and execute the requested operations.