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
];

    Access your files securely from anywhere









                          Zoho Developer Community




                                                • Desk Community Learning Series


                                                • Digest


                                                • Functions


                                                • Meetups


                                                • Kbase


                                                • Resources


                                                • Glossary


                                                • Desk Marketplace


                                                • MVP Corner


                                                • Word of the Day


                                                • Ask the Experts





                                                          Manage your brands on social media



                                                                Zoho TeamInbox Resources



                                                                    Zoho CRM Plus Resources

                                                                      Zoho Books Resources


                                                                        Zoho Subscriptions Resources

                                                                          Zoho Projects Resources


                                                                            Zoho Sprints Resources


                                                                              Qntrl Resources


                                                                                Zoho Creator Resources



                                                                                    Zoho CRM Resources

                                                                                    • CRM Community Learning Series

                                                                                      CRM Community Learning Series


                                                                                    • Kaizen

                                                                                      Kaizen

                                                                                    • Functions

                                                                                      Functions

                                                                                    • Meetups

                                                                                      Meetups

                                                                                    • Kbase

                                                                                      Kbase

                                                                                    • Resources

                                                                                      Resources

                                                                                    • Digest

                                                                                      Digest

                                                                                    • CRM Marketplace

                                                                                      CRM Marketplace

                                                                                    • MVP Corner

                                                                                      MVP Corner







                                                                                        Design. Discuss. Deliver.

                                                                                        Create visually engaging stories with Zoho Show.

                                                                                        Get Started Now


                                                                                          Zoho Show Resources

                                                                                            Zoho Writer

                                                                                            Get Started. Write Away!

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

                                                                                              Zoho CRM コンテンツ






                                                                                                Nederlandse Hulpbronnen


                                                                                                    ご検討中の方