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

Free Support Forum - aspose.com

Few questions about vcf


We have tested the scenario using the same code example shared in this forum thread.

  1. Regarding font issue, all text of MHTML has font ‘Times New Roman’. Please share the complete code that you are using for this issue.
  2. Could you please share how you want the subject of MHTML file? Please share the expected MHTML.
  3. Set From of output MHTML as contact’s Email1. We logged this issue as EMAILNET-40738.
  4. The image does not export in output MHTML. It is expected behavior.
  1. If you set WriteHeader + RenderVCardInfo then all text won’t be Times New Roman
    As you can see in the attached png
  2. From the subject of contact file, but if you mean mhtml cannot have Subject, use IE to save a page as mhtml and inspect it to see the Subject in the 3rd line
    Thanks :slight_smile:


We will investigate your issue further and will get back to you soon.

Thanks again, but add the note that this whole issue is not my priority, if it takes more than expected time, you may totally leave it and close the case, the bug fixes are much more critical, specially some new ones that I found and am trying to make the docs to report :frowning:


Please spare us some time. We will get back to you soon.


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