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.com” gparm_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)
.

regards
Tarun

@genpact

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


		saveOptions.setSaveAttachments(true);
		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.setName(attFileName);
				att.setContentStream(new ByteArrayInputStream("".getBytes()));
			}
		}
		mailMsg.setFrom(mailMsg.getFrom());
				mailMsg.save(path+"Saved.mht", saveOptions);
    }

@mudassir.fayyaz

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

regards
Tarun