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”
To: “”
CC: “Srivastava, Tarun”
it print only double quotes value
like it print To Srivastava, Tarun
i am expected To “Srivastava, Tarun”

attaching sample EML and sample code in zip file for your reference
Sample (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.setFrom(mailMsg.getFrom());"Saved.mht", saveOptions);


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