0

I am getting mail content as object instead of HTML content... Here is my Magento Code

//mail
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('catalog/session');

//get customer details
$customer = Mage::getSingleton('customer/session')->getCustomer();
$customer->getId();  
$customer->getEmail();  

//get general store details
$from_name = Mage::getStoreConfig('trans_email/ident_general/name');
$from_email = Mage::getStoreConfig('trans_email/ident_general/email');
$templateId = 7;        // My Email Template ID
$emailTemplate = Mage::getModel('core/email_template')->load($templateId);

$mail = Mage::getModel('core/email');
$mail->setToName($from_name);
$mail->setToEmail($from_email);
$mail->setBody($emailTemplate);
$mail->setSubject('Sample Mail Subject');
$mail->setFromEmail($customer->getEmail());
$mail->setFromName("Msg to Show on Subject");
$mail->setType('Html');

try {
    $mail->send();
    Mage::getSingleton('core/session')->addSuccess('Your request has been sent');   
}
catch (Exception $e) {
    Mage::getSingleton('core/session')->addError('Unable to send.');
}

I want the HTML contents of the template as the output.

Please Help ! Thank you.

1 Answer 1

0

I think you need to process your template.

$processedTemplate = $emailTemplate->getProcessedTemplate();
........
.........
$mail->setBody($processedTemplate);

I haven't tested though. But should work.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.