Recently, during a custom extension development, there was a requirement to send customers’ an Email regarding the price. And, for this, I had to load all the default Magento Email templates.

I used the below code to get a list of Email templates programmatically in Magento 2 and you can use it too, whenever you want to send an Email from the Magento 2 store.
Select the desired Email template from the list and hence the right Email will be sent accordingly to the customers.
Method to get a list of Email templates programmatically in Magento 2:
Create app/code/Vendor/Extension/Helper/Data.php:
<?php namespace Vendor\Extension\Helper; use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\Context; use Magento\Email\Model\Template\Config; class Data extends AbstractHelper { private $emailTemplateConfig; public function __construct(Context $context, Config $emailTemplateConfig) { $this->emailTemplateConfig = $emailTemplateConfig; parent::__construct($context); } public function getEmailTemplateOptionArray() { return $this->emailTemplateConfig->getAvailableTemplates(); } }
That’s it.
Do share the solution to fellow developers via social media.
Thanks.