ईमेल संदेश को PDF के रूप में सहेजें
Contents
[
Hide
]
Aspose.Email - ईमेल संदेश को PDF के रूप में सहेजें
निम्नलिखित कोड दिखाता है कि Aspose.Email को Aspose.Words for Java के साथ मिलाकर ईमेल संदेश को PDF में कैसे रूपांतरित किया जाए। इसमें निम्नलिखित चरण शामिल हैं:
- MailMessage का उपयोग करके ईमेल संदेश लोड करें
- ईमेल संदेश को MemoryStream में MHTML के रूप में सहेजें
- Aspose.Words का उपयोग करके स्ट्रीम लोड करें
- संदेश को PDF के रूप में सहेजें
Java
FileInputStream fstream = new FileInputStream(dataDir + "message.msg");
MailMessage eml = MailMessage.load(fstream);
// Save the Message to output stream in MHTML format
ByteArrayOutputStream emlStream = new ByteArrayOutputStream();
eml.save(emlStream, SaveOptions.getDefaultMhtml());
// Load the stream into a Word document; the Aspose.Words types are qualified
// because com.aspose.email has a LoadOptions class of its own
com.aspose.words.LoadOptions lo = new com.aspose.words.LoadOptions();
lo.setLoadFormat(com.aspose.words.LoadFormat.MHTML);
com.aspose.words.Document doc = new com.aspose.words.Document(
new ByteArrayInputStream(emlStream.toByteArray()), lo);
// Save to disk
doc.save(dataDir + "message.pdf", com.aspose.words.SaveFormat.PDF);
// or save to a stream
ByteArrayOutputStream foStream = new ByteArrayOutputStream();
doc.save(foStream, com.aspose.words.SaveFormat.PDF);
चल रहा कोड डाउनलोड करें
नमूना कोड डाउनलोड करें
अधिक विवरण के लिए देखें MSG को PDF के रूप में सहेजना.