@australian.dev.nerds
1.Make this font like header above.
Special cases of HTML rendering are not the responsibility of Aspose.Email, but Aspose.Email provides MhtSaveOptions.CssStyles property so that the you can customize the desired output. In the code below, we explained a simple example of how you can use this property to set one font for all text.
4.Add all contact attachments to the resulting mhtml i.e., ContactPicture.jpg etc.
There are no attachment rendering issues on our side. Please check the attached MHTML files.
mhtml.zip (221.0 KB)
2.Set Subject resulting mhtml as Contact’s subject, which is: Mu.First Middle LastJr.
3.Set From of resulting mhtml as Contact’ Email1
We did not quite understand this requirement that you want. The MHTML is created for messages and contacts with different sets of fields, for messages the fields meet your requirements.
If the you want to add these headers to the resulting MHTML then this possibility is not provided, only the MIME-Version: and Content-Type: headers are present (as implemented in Outlook).
Please check the following code example. Hope this helps you.
MapiContact contact = MapiContact.FromVCard("input.vcf");
MemoryStream ms = new MemoryStream();
contact.Save(ms, ContactSaveFormat.Msg);
ms.Position = 0;
MapiMessage msg = MapiMessage.Load(ms);
MailConversionOptions op = new MailConversionOptions();
MailMessage eml = msg.ToMailMessage(op);
if (contact.ElectronicAddresses.Email1 != null)
eml.From = new MailAddress(contact.ElectronicAddresses.Email1.EmailAddress);
MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();
//set font family, size and style for body as in headers
mhtSaveOptions.CssStyles = mhtSaveOptions.CssStyles
.Replace("font-weight:bold;", "font-weight:normal;")
.Replace("</style>", ".PlainText {font-family: \"Calibri\",\"sans-serif\";font-size:11.0pt;font-weight:normal;}</style>");
mhtSaveOptions.SaveAttachments = true;
eml.Save(fileName + "out_msg.mhtml", mhtSaveOptions);
mhtSaveOptions = new MhtSaveOptions();
//set font family, size and style for body as in headers
mhtSaveOptions.CssStyles = mhtSaveOptions.CssStyles
.Replace("font-weight:bold;", "font-weight:normal;")
.Replace("</style>", "body {font-family: \"Calibri\",\"sans-serif\";font-size:11.0pt;font-weight:normal;}</style>");
mhtSaveOptions.SaveAttachments = true;
//set field set for contact
mhtSaveOptions.MhtFormatOptions = mhtSaveOptions.MhtFormatOptions | MhtFormatOptions.RenderVCardInfo;
mhtSaveOptions.RenderedContactFields = ContactFieldsSet.AllExisting;
eml.Save(fileName + "out_contact.mhtml", mhtSaveOptions);
//change header name for needed
mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Email] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Email].Replace("Email", "From");
mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.FullName] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.FullName].Replace("Full Name", "Subject");
eml.Save(fileName + "out_contact2.mhtml", mhtSaveOptions);