Convert EMail (.EML) file to PDF
Hi
Currently we are attaching .EML (Email) file to case attachment using email listener which is coming from external system. I have requirement to convert .EML file (Email) to pdf file and attach it to the case. I am trying to use the base 64 code of .EML file and save it as pdf file, but I am not able to open it. It is not working. Do we need to make any changes to base64 code of .EML file to make it convert it to pdf format. Application is built on Constellation
@Anudeep B You cannot turn an EML into a PDF by just base64 saving it as .pdf. An EML is a MIME email, so first parse it, then render its body, then convert that HTML to PDF. In Pega, read the EML attachment bytes, use a Java step with JavaMail to build a MimeMessage, walk the parts, and pick text/html if present, else wrap text/plain in simple HTML. Resolve inline cid images by pulling the related parts and inlining them as data URIs so the PDF renderer can see them. Feed the final HTML string to Code-Pega-PDF.HTMLToPDF or the Create PDF utility to produce a PDF byte array. Attach that output using pxAttachContent or pxAddAttachment with content type application/pdf and your desired category so it shows in the case. Run this in the email listener post-processing or a small activity on case creation so every incoming EML yields a sibling PDF. Add size limits and a fallback for unsupported CSS, and log failures so you can review bad messages later. If JavaMail use is restricted, call an internal conversion service that accepts EML and returns PDF, then attach that result.