Beispiel #1
0
        internal void SetBody(string value)
        {
            if (ContentTransferEncoding.Is("quoted-printable"))
            {
                value = Utilities.DecodeQuotedPrintable(value, Utilities.ParseCharsetToEncoding(Charset));
            }
            else if (ContentTransferEncoding.Is("base64")
                     //only decode the content if it is a text document
                     && ContentType.StartsWith("text/", StringComparison.OrdinalIgnoreCase) &&
                     Utilities.IsValidBase64String(value))
            {
                value = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(value));
                ContentTransferEncoding = string.Empty;
            }

            Body = value;
        }
        internal void SetBody(string value)
        {
            if (ContentTransferEncoding.Is("quoted-printable"))
            {
                value = Utilities.DecodeQuotedPrintable(value, Encoding);
            }
            else if (ContentTransferEncoding.Is("base64")
                     //only decode the content if it is a text document
                     && ContentType.StartsWith("text/", StringComparison.OrdinalIgnoreCase) &&
                     Utilities.IsValidBase64String(value))
            {
                var data = Convert.FromBase64String(value);
                using (var mem = new System.IO.MemoryStream(data))
                    using (var str = new System.IO.StreamReader(mem, Encoding))
                        value = str.ReadToEnd();

                ContentTransferEncoding = string.Empty;
            }

            Body = value;
        }