Sending emails in Salesforce Apex using the native Messaging class often results in verbose, repetitive boilerplate. Configuration takes multiple lines, readability suffers, and maintaining email logic becomes harder over time.
LSend is an open source fluent email API that dramatically simplifies how developers send emails from Apex. With clean method chaining and built in support for templates, attachments, and ContentVersion records, LSend makes email logic expressive, readable, and maintainable.
🔎 Why LSend?
Traditional Apex email setup usually involves:
- Multiple object initialisations
- Repetitive recipient configuration
- Manual attachment wiring
- Verbose template rendering
LSend replaces all of this with a clean, expressive fluent chain.
✨ Fluent Email in Apex
LSend.emails()
.sender('onboarding@salesforce.com')
.to('user@gmail.com')
.subject('Hello World')
.html('<strong>It works!</strong>')
.send();
This reduces complexity by roughly 70% compared to native Messaging.SingleEmailMessage implementations while making the intent of the code immediately clear.
🔥 Key Features
1️⃣ Multiple Recipients
LSend.emails()
.sender('Support <support@company.com>')
.to('customer@example.com')
.cc('manager@company.com')
.subject('Your ticket has been received')
.html('<p>We will respond within 24 hours.</p>')
.send();
2️⃣ HTML, Text, and Template Support
LSend.emails()
.sender('noreply@company.com')
.to('user@example.com')
.subject('Welcome to Our Platform!')
.staticResource('WelcomeEmail', new Map<String, String>{
'name' => 'John',
'company' => 'Acme Inc'
})
.send();
3️⃣ Attachments and ContentVersion Integration
Blob pdfContent = PageReference.getContent();
LSend.emails()
.sender('billing@company.com')
.to('customer@example.com')
.subject('Invoice #12345')
.html('<p>Your invoice is attached.</p>')
.attach('invoice.pdf', pdfContent)
.attachContentVersions(contentVersionIds)
.send();
LSend works seamlessly with Salesforce ContentVersion and native email functionality.
⚙️ Installation
Deploy the following classes into your org from:
force-app/main/default/classes
LSend.clsEmailBuilder.clsEmailAttachment.clsEmailResult.clsEmailException.cls
sf project deploy start --source-dir force-app/main/default/classes
⚠️ Important Considerations
UTF-8 Encoding
System.StringException: BLOB is not a valid UTF-8 string
Governor Limits
- Up to 5,000 emails per day depending on edition
- Maximum of 150 recipients per email
- Total attachment size capped at 25 MB per email
💡 Why This Matters for Salesforce Developers
- Faster development
- Easier maintenance
- Reduced technical debt
- Improved readability for teams
LSend modernises Apex email sending while staying fully compatible with Salesforce’s native infrastructure.
🌍 Sources
If you enjoy discovering practical Salesforce developer tools like this, explore more deep dive content, real world patterns, and certification prep at:
👉 https://www.consultantcloud.io/