This project is read-only.

Attachment download throws exception for csv-formatted *txt files


Hi! I have been using ImapX 2 for quite some time ( and recently ran into a problem when trying to fetch email attachments from hMailServer. Please have a look at the files attached; the same file with 3 different formats. Whenever I try to download one of these files with ImapX, I get the following exception: "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters. " My code looks like this:
 byte[] fileData = null;
 string fileName = null;

foreach (var attachment in message.Attachments)
      if (!attachment.Downloaded) 

      var contentType = attachment.ContentType; //usually starts with "application/"
      fileName = attachment.FileName;
      fileData = attachment.FileData; //EXCEPTION OCCURS HERE
   catch(Exception ex) {}
The stacktrace is as follows:
   at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength)
   at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
   at System.Convert.FromBase64CharArray(Char[] inArray, Int32 offset, Int32 length)
   at System.Security.Cryptography.FromBase64Transform.TransformBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[] outputBuffer, Int32 outputOffset)
   at ImapX.EncodingHelpers.Base64.FromBase64(String s)
   at ImapX.Attachment.get_FileData()
   at Frontend.Classes.LocalEmailClient.ParseMessage(Message message) 
A similar issue was posted here:
The code works when downloading *wav files and since this error appears to come from within the ImapX libary, I was hoping someone here could help me in resolving this.

file attachments