Ejemplo n.º 1
0
        private string ParseBodyPart(IMAP.BodyPartEncoding encoding, Encoding en)
        {
            string response;

            en = System.Text.Encoding.GetEncoding("ISO-8859-9");
            StringBuilder sb = new StringBuilder("");

            do
            {
                response = Connection.Read();

                if (response.IndexOf("FLAGS") != -1)
                {
                    continue;
                }
                if (Regex.IsMatch(response, patFetchComplete))
                {
                    break;
                }
                if (encoding == IMAP.BodyPartEncoding.BASE64)
                {
                    sb.Append(response + '\r' + '\n');
                }
                else if (encoding == IMAP.BodyPartEncoding.QUOTEDPRINTABLE)
                {
                    response = response.Replace("=FC", "ü");
                    response = response.Replace("=DC", "Ü");
                    response = response.Replace("=F0", "ð");
                    response = response.Replace("=D0", "Ð");
                    response = response.Replace("=F6", "ö");
                    response = response.Replace("=D6", "Ö");
                    response = response.Replace("=E7", "ç");
                    response = response.Replace("=C7", "Ç");
                    response = response.Replace("=FD", "ý");
                    response = response.Replace("=DD", "Ý");
                    response = response.Replace("=FE", "þ");
                    response = response.Replace("=DE", "Þ");
                    response = response.Replace("=3D", "=");
                    response = response.Replace("_", " ");
                    response = response.Replace("=5F", "_");


                    if (response.EndsWith("=") || response.EndsWith(")"))
                    {
                        sb.Append(response.Substring(0, response.Length - 1));
                    }
                    else
                    {
                        sb.AppendLine(response);
                    }
                }
                else
                {
                    sb.AppendLine(response + '\r' + '\n');
                }
            } while (true);
            //} while (!(response.EndsWith("==") || response == ")"));
            if (sb.ToString().Trim().EndsWith(")"))
            {
                sb = sb.Remove(sb.ToString().IndexOf(")"), 1);
            }
            if (encoding != BodyPartEncoding.BASE64)
            {
                return(ImapDecode.Decode(sb.ToString(), en));
            }

            // return sb.ToString().Substring(0,sb.Length-15);

            //----------------------------------//
            return(sb.ToString());
            //----------------------------------//
        }
Ejemplo n.º 2
0
 private string ParseBodyPart(IMAP.BodyPartEncoding encoding)
 {
     return(ParseBodyPart(encoding, null));
 }