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

Free Support Forum - aspose.com

Few questions about vcf


Please also attach the problematic and expected output MHTML files here for our reference. We will investigate the issue and provide you more information on it.

Thanks, attachedDesktop.zip (347.8 KB)

Can you also please kindly explain the details of:

Email.MhtFormatOptions.DisplayAsOutlook option?

Setting it will make no difference in my output mhtml


We have logged this problem in our issue tracking system as EMAILNET-40724. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


Support for the VCardVersion 4.0 format has not been implemented due to its not prevalence. For example, Outlook saves contacts in the VERSION:2.1 format.

Outlook also does not render contact photos when saved in RTF. This feature is not supported by Aspose.Email.

Font settings for headers are set using CSS and can be cleared with a simple code. After that, all fonts will be the same.

mhtSaveOptions.CssStyles = mhtSaveOptions.CssStyles.Replace("font-weight:bold;", string.Empty)
                .Replace("font-family:\"Calibri\",\"sans-serif\";", string.Empty);

The email of contact rendered in Email header. The name of header “Email” may be renamed to “From/To” by simple code:

mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Email] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Contact.Email].Replace("Email", "From/To");

This option is make sense only for messages, not for Contact and Calendar. It provide rendering sender’s DisplayName only, without email address as it makes Outlook.

Thanks for your help, if you don’t mind I’ve just some final questions:
When converting vcf vcard to message, I wanna get the email address of contact file and assign it to the sender of final eml message.
Please advise if I should look in Contact.ElectronicAddresses.DefaultEmailAddress or Contact.ElectronicAddresses.Email1?

Is it possible that Contact.ElectronicAddresses.Email2 or Contact.ElectronicAddresses.Email3 has an email address while Contact.ElectronicAddresses.Email1 does not have?
Or those three will be loaded in order so if there’s an email, must be in Contact.ElectronicAddresses.Email1…

Seems that Contact.ElectronicAddresses.DefaultEmailAddress will not be nothing, but a “N/A” string right? not the case about Contact.ElectronicAddresses.Email1

To assign that email address to the resulting msg or eml?
When saving Email.Mapi.MapiContact.Save(MSG, Email.Mapi.ContactSaveFormat.Msg)
or when saving as eml MSG.ToMailMessage(MyOptions)
setting MSG.SenderName = “sender name from above”
setting MSG.SenderEmailAddress = “sender email from above”
nothing happens!
Mail As Email.MailMessage = MSG.ToMailMessage(MyOptions)
Mail.From = “email from above”
also nothing happens!


A ticket EMAILNET-40731 has been logged for your requirement. We will inform you once there is an update available on it.

Thanks, as you have noticed, I’m done with the small part of my development, just waiting for the open cases (fixes/ how tos) :frowning:


You should look in Contact.ElectronicAddresses.Email1. The Contact.ElectronicAddresses.DefaultEmailAddress always contains “N/A” string if you don’t change it by yourself.

The answer is ‘No’.

These addresses is read in order, if VCF file contains one Email field then Contact.ElectronicAddresses.Email1 will be filled.

If VCF file contains three Email fields then first will be Email1, second - Email2, third - Email3.

Please use the following code example to populate the From field.

MapiContact contact = MapiContact.FromVCard("fds fsd fds fsdfds.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);
eml.Save(fileName + ".eml");

Thanks for the code snippet, this fixed the “From” field, but will save a blank Eml message

If I use:
eml.Save(fileName + “.eml” , MhtSaveOptions);

MhtSaveOptions.RenderedContactFields = Email.ContactFieldsSet.AllExisting
MhtSaveOptions.SaveAttachments = True
Dim MyFormatOptions As Email.MhtFormatOptions = Email.MhtFormatOptions.WriteHeader Or Email.MhtFormatOptions.RenderVCardInfo Or Email.MhtFormatOptions.WriteOutlineAttachments
MhtSaveOptions.MhtFormatOptions = MyFormatOptions

Adding WriteComplete(From)EmailAddress won’t help

The From field is lost, back to the 1st step :frowning:

I need to set MhtFormatOptions.WriteHeader + MhtFormatOptions.RenderVCardInfo + MhtFormatOptions.WriteOutlineAttachments which will clear the eml.From :frowning:

I’ve inspected the final result stream/file
This seems a bug in MailMessage not saving the From or Subject etc headers if we set those MhtFormatOptions

  • Even if we set “From” , “Subject” etc in the MapiMessage msg , still not being added to the final result

This completely removes the formatting (WriteHeader / RenderVCardInfo)
I meant apply the header font format to the rest of output message
In this case, make the Notes section’s font identical to the header.
My original snapshot:


The MhtSaveOptions is used for MHTML file format. However, MailMessage.Save method saves the file to EML.

The code snippet you are using in this post is incorrect. So, the correct code was shared with you.

To ensure a timely and accurate response, please attach the following resources here for testing:

  • If you are not using ‘fds fsd fds fsdfds.vcf’ file, please share your input file.
  • Please attach the output file that shows the undesired behavior.
  • Please attach the expected output file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

The MhtSaveOptions is used for MHTML file format. However, MailMessage.Save method saves the file to EML.

Hello, AFAIK eml and mhtml are the same formats with different extensions, there can be minor fine tunes per extension though.

BTW, if you mean this is wrong:
eml.Save(fileName + “.eml” , MhtSaveOptions);

Does not seem so, because WriteHeader / RenderVCardInfo / WriteOutlineAttachments which all shapes the VCF to EML output, do not exist in EmlSaveOptions.

In addition, this is the way you’re using in your own sample here:

So I guess there’s a misunderstanding here…


Please note that MhtSaveOptions class is used for MHTML save options and EmlSaveOptions class is used or EML save options.

You can share your sample input VCF along with expected output EML here for our reference. We will check the detail and provide you more information on it.

You are saving VCF to MHTML. In this case, you need to save the VCF to MSG file. Once you have the MSG file, you can apply all related properties of EmlSaveOptions or MhtSaveOptions to export the MSG to MHTML or EML.

We suggest you please save your VCF to MSG file first and let us know if there is any issue. If the MSG file is incorrect, the MHTML will not be as expected.

However, this is not vital for me, although would be nice :slight_smile:

Documents.zip (208.7 KB)


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.