Ejemplo n.º 1
0
        private void DecodeData()
        {
            // if this data is an attachment ...
            // if BASE-64 data ...
            if (_contentTransferEncoding != null)
            {
                if (_contentTransferEncoding.ToUpper()
                    .Equals("BASE64"))
                {
                    // convert attachment from BASE64 ...
                    BinaryData =
                        Convert.FromBase64String(_data.Replace("\n", ""));

                    _data = System.Text.Encoding.ASCII.GetString(BinaryData);
                }
                else
                // if PRINTABLE ...
                if (
                    _contentTransferEncoding.ToUpper()
                    .Equals("QUOTED-PRINTABLE"))
                {
                    _data = Pop3Statics.FromQuotedPrintable(_data);
                }
            }
        }
Ejemplo n.º 2
0
        internal static string Subject(string line)
        {
            var subject =
                Regex.Replace(line
                              , @"^Subject: (.*)$"
                              , "$1");
            var match = Regex.Match(subject, @"=\?(?<charset>[^\?]+)\?(?<encoding>[BQ])\?(?<data>[^\?]+)\?=");

            if (match.Success)
            {
                if (match.Groups["encoding"].Value == "B")
                {
                    var data = Convert.FromBase64String(match.Groups["data"].Value);
                    return(Encoding.ASCII.GetString(data));
                }
                else
                {
                    return(Pop3Statics.FromQuotedPrintable(match.Groups["data"].Value));
                }
            }
            return(subject);
        }