When you use your custom Email for your module, there is a chances to get empty content section in your email output. Or you will not get any HTML output from your email content output. This is depend on the way what we are implementing. If you need HTML output in your email then use .phtml file instead of .html. Write the logic with HTML format of output from your .phtml file and return the output.
Step:1 app/code/Jute/Ecommerce/Cron/MyCustomEmailSend.php
In this file you can load your email template & you can trigger the Email.
Ex: Load by Email Template “mymodule_template” & trigger email.
Step:2 app/code/Jute/Ecommerce/view/frontend/email/mymodule_template.xml
{{template config_path=”design/email/header_template”}}
<h4>Custom Email Template:</h4>
{{block class=”Magento\Framework\View\Element\Template ” name=”custom.email” template=”Embitel_Commerce::mydetail.phtml”}}
{{template config_path=”design/email/footer_template”}}
Step:3 app/code/Jute/Ecommerce/view/frontend/templates/pendingorder.phtml
In this file you should call your block or model or helper with the helper of Objectmgmt. Why because the same script will work when you trigger the URL from the browser. But when you execute the email template via Cron then this block won’t return any thing. Block name will deffer when your execute it from Cron & Browser.
Below code is wrong when you trigger via Cron, but will work when you trigger via Controller URL
echo $block->getOrderWithPendingStatus();
Cron : In this case $block will return the class as “Jute\Ecommerce\Block\Myblockfileclass ”
Controller URL : In this case $block will return the class as “Magento\Framework\View\Element\Template ”
To resolve this issue we have to write our business logic from helper class or model class. Using Objectmgmt we have to pass entire path as like below.
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
echo $objectManager->create(‘Jute\Ecommerce\Model\Mymodel’)->getCustomEmailOutputwithHTMLFormat();
?>
Step:4 app/code/Jute/Ecommerce/Model/Mymodel.php
In this file you can write your Email content section result as HTML format & return the value.