Search code examples
e-commercepaymentemail-attachmentskenticoinvoice

Attachment to eCommerce email Template of kentico cms


I am developing shopping website using kentico cms 9. In the website I want to send invoice to customer as a pdf attachment of email template (default kentico ecommerce email template).currently I am sending invoice in email body of email template and its Woking fine. But now I want to send Invoice as a pdf attachment as well as in email body also. Is this possible to send invoice with attachment of email template in kentico cms.


Solution

  • Yes, you can send email attachments using the API. I believe this code is still valid for v11.

    var emailTemplate = EmailTemplateProvider.GetEmailTemplate("yourtemplatename", "yoursitename");
    MetaFileInfoProvider.GetMetaFiles(emailTemplate.TemplateID, "cms.emailtemplate", "Template", "", "");
    

    Creating the invoice into a PDF is not out of the box though, you'd have to include a 3rd party tool to do that conversion for you. Once you have the order, you can simply call order.OrderInvoice and it will render all the macros in the order invoice template and get you the HTML you need to send to a PDF to be created.