Convert HTML to PDF & Send as Email Attachments in Zoho Creator (Deluge)

Convert HTML to PDF & Send as Email Attachments in Zoho Creator (Deluge)

This approach is useful for sending welcome letters, instructions, or promotional offers after order creation.

// 1. Define the variables using the submitted input
customerName = input.Customer_Name1;
orderID = input.ID;
customerEmail = input.Email_Address;

// 2. Define the HTML Content for each PDF separately

// --- HTML for PDF 1 (Welcome) ---
html1 = "<html><head><meta charset='utf-8'/>"
    + "<style> ... your CSS styles ... </style></head><body>"
    + "<div class='container'>"
    + "<h1>Confirmation & Welcome</h1>"
    + "<div>Hello <b>" + customerName + "</b>, thank you for your order.</div>"
    + "</div></body></html>";

// --- HTML for PDF 2 (Instructions) ---
html2 = "<html><head><meta charset='utf-8'/>"
    + "<style> ... CSS styles ... </style></head><body>"
    + "<h2>Next Steps & Processing</h2>"
    + "<div>Review your shipping and contact details.</div>"
    + "</body></html>";

// --- HTML for PDF 3 (Special Offer) ---
``      html3 = "<html><head><meta charset='utf-8'/>"
    + "<style> ... CSS styles ... </style></head><body>"
    + "<h3>Special Offer — Thank you!</h3>"
    + "<div>Use coupon <b>SAVE15</b> on your next order.</div>"
    + "</body></html>";

// 3. Convert each HTML string into a separate PDF file object
pdfFile1 = zoho.file.convertToPDF(html1);
pdfFile2 = zoho.file.convertToPDF(html2);
pdfFile3 = zoho.file.convertToPDF(html3);

// 4. Send email with all PDFs attached
sendmail
[
    from: zoho.adminuserid
    to: customerEmail
    subject: "Your Order Documents - Order #" + orderID
    message: "Dear " + customerName + ", please find your documents attached."
    attachments: file:pdfFile1, file:pdfFile2, file:pdfFile3
];


      Zoho Campaigns Resources


        • Desk Community Learning Series


        • Digest


        • Functions


        • Meetups


        • Kbase


        • Resources


        • Glossary


        • Desk Marketplace


        • MVP Corner


        • Word of the Day


        • Ask the Experts


          Zoho CRM Plus Resources

            Zoho Books Resources


              Zoho Subscriptions Resources

                Zoho Projects Resources


                  Zoho Sprints Resources


                    Zoho Orchestly Resources


                      Zoho Creator Resources


                        Zoho WorkDrive Resources



                          Zoho CRM Resources

                          • CRM Community Learning Series

                            CRM Community Learning Series


                          • Tips

                            Tips

                          • Functions

                            Functions

                          • Meetups

                            Meetups

                          • Kbase

                            Kbase

                          • Resources

                            Resources

                          • Digest

                            Digest

                          • CRM Marketplace

                            CRM Marketplace

                          • MVP Corner

                            MVP Corner




                            Zoho Writer Writer

                            Get Started. Write Away!

                            Writer is a powerful online word processor, designed for collaborative work.

                              Zoho CRM コンテンツ






                                ご検討中の方