+1 vote

When reading information about attachment using BodyStructure.Visuals and BodyStructure.NonVisuals, I cannot find a way to get the text encoding of an attached text file.

Currently I try to read Vcards "text/x-vcard; charset=iso-8859-1". How can I get the charset?

by

1 Answer

0 votes
 
Best answer

You can cast objects, that represent text MIME entities, in BodyStructure's Visuals/NonVisuals/Attachments to MimeTextStructure class.

It has Data, Charset, Encoding and Text properties.

As BodyStructure instance is created by invoking Imap.GetMessageInfoByUID or Imap.GetBodyStructureByUID, Data and Text properties are not filled. Both methods download only most common information about the email structure without downloading actual attachment data.

You can use Imap.GetDataByUID or Imap.GetTextByUID to fill Data and Text.

Text property already takes charset into account, so you don't need to use it directly.

by (297k points)
...