Arthur Dudnik - 2007-04-27

Curent build [0.5.8b] not support long subject :(

Example header for email with long subject:

Subject: =?utf-8?B?0JTQu9C40L3QvdGL0LksINCX0LDQs9C+0LvQvtCy0L7QuiDQuNC3INCg0YPRgdGB0LrQuNGFINCx
0YPQutCy?=

Test Param: Base64, UTF-8
For support I change function in DotNetOpenMail.Encoding

        public String EncodeHeaderString(String name, String val, System.Text.Encoding charset, bool forceencoding)
        {
            String result = string.Empty;
            int line_len = 18;
            int count = (int)Math.Ceiling((decimal)val.Length / line_len);

            for (int i = 0; i < count; i++)
            {
                int len = val.Length < (i + 1) * line_len ? val.Length - i * line_len : line_len;

                byte[] sourceBytes = new byte[len];
                sourceBytes = charset.GetBytes(val.Substring( i * line_len, len));

                result += (i > 0 ? "      " : string.Empty) + "=?" + charset.HeaderName + "?B?" + Convert.ToBase64String(sourceBytes) + "?=" + (i < count - 1 ? Base64Encoder.END_OF_LINE : string.Empty);

            }
            return result;

            //String encodedtext=EncodeString(val, charset);
            //return "=?" + charset.HeaderName + "?B?" + encodedtext + "?=";
           
        }

But I think this change contain more bug... Any suggestion?