We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

EmailTo, EmailFrom and emailCC values EML to pdf

Hi Team,

I am trying to convert eml to pdf, where I am trying to print EmailTo, CC and From value

From: “Srivastava, Tarun” tarun.srivastava@genpact.digital
To: “gparm_ver_dev5@pvai.comgparm_ver_dev5@pvai.com
CC: “Srivastava, Tarun” tarun.srivastava@genpact.digital
it print only double quotes value
like it print To Srivastava, Tarun
i am expected To “Srivastava, Tarun” tarun.srivastava@genpact.digital

attaching sample EML and sample code in zip file for your reference
Sample code.zip (7.8 KB)



You need to add header values in MhtSaveOptions using following sample code.

    public static void TestMhtml()
        String path="C:\\Users\\mudas\\Downloads\\Sample code (1)\\";
        MailMessage mailMsg;
		ByteArrayOutputStream arrayOutputStream = null;
		MhtSaveOptions saveOptions;
		mailMsg = MailMessage.load(path+"test.eml", new EmlLoadOptions());
		arrayOutputStream = new ByteArrayOutputStream();
		saveOptions = SaveOptions.getDefaultMhtml();
                saveOptions.setMhtFormatOptions(MhtFormatOptions.WriteHeader | MhtFormatOptions.WriteCompleteEmailAddress);

		AttachmentCollection attachmentCollection = mailMsg.getAttachments();
		if (attachmentCollection != null) {
			int size = attachmentCollection.size();
			for (int i = 0; i < size; i++) {
				Attachment att = attachmentCollection.get_Item(i);
				String attFileName = att.getName().replace(":", " ").replace("\\", " ").replace("/", " ")
						.replace("?", "").replace(">", "").replace("<", "").replace("|", "");
				att.setContentStream(new ByteArrayInputStream("".getBytes()));
				mailMsg.save(path+"Saved.mht", saveOptions);


Thanks for code , let me try and will update you soon.