Пример #1
0
        protected void EncodeNoDelimeter(string s, StringBuilder sb)
        {
            if (Charset == null)
            {
                Charset = System.Text.Encoding.Default.BodyName;
            }

            switch (SelectEncoding(s).ToLower())
            {
            case "non": sb.Append(s); break;

            case "quoted-printable":
            {
                MimeCode aCode = MimeCodeManager.Instance.GetCode("quoted-printable");
                aCode.Charset = Charset;
                sb.AppendFormat("=?{0}?Q?{1}?=", Charset, aCode.EncodeFromString(s));
                break;
            }

            case "base64":
            {
                MimeCode aCode = MimeCodeManager.Instance.GetCode("base64");
                aCode.Charset = Charset;
                sb.AppendFormat("=?{0}?B?{1}?=", Charset, aCode.EncodeFromString(s));
                break;
            }
            }
        }
Пример #2
0
        protected void EncodeDelimeter(string s, StringBuilder sb)
        {
            char[]   filter      = GetDelimeterChars();
            string[] strArr      = s.Split(filter);
            int      filterIndex = 0;

            for (int i = 0; i < strArr.Length; i++)
            {
                filterIndex += strArr[i].Length;
                if (strArr[i] != null)
                {
                    if (Charset == null)
                    {
                        Charset = System.Text.Encoding.Default.BodyName;
                    }

                    switch (SelectEncoding(strArr[i]).ToLower())
                    {
                    case "non": sb.Append(strArr[i]); break;

                    case "quoted-printable":
                    {
                        MimeCode aCode = MimeCodeManager.Instance.GetCode("quoted-printable");
                        aCode.Charset = Charset;
                        sb.AppendFormat("=?{0}?Q?{1}?=", Charset, aCode.EncodeFromString(strArr[i]));
                        break;
                    }

                    case "base64":
                    {
                        MimeCode aCode = MimeCodeManager.Instance.GetCode("base64");
                        aCode.Charset = Charset;
                        sb.AppendFormat("=?{0}?B?{1}?=", Charset, aCode.EncodeFromString(strArr[i]));
                        break;
                    }
                    }
                }
                if (filterIndex < s.Length)
                {
                    sb.Append(s.Substring(filterIndex, 1));
                }
                filterIndex += 1;
            }
        }
Пример #3
0
        //store a field content to a string buffer
        public void Store(StringBuilder sb)
        {
            if (sb == null)
            {
                throw new ArgumentNullException();
            }

            MimeCode aFieldCode = MimeCodeManager.Instance.GetCode(GetName());

            if (aFieldCode != null)
            {
                aFieldCode.Charset = m_strCharset;
                sb.AppendFormat("{0}: {1}\r\n", m_strName, aFieldCode.EncodeFromString(m_strValue));
            }
            else
            {
                sb.AppendFormat("{0}: {1}\r\n", m_strName, m_strValue);
            }
        }
Пример #4
0
        public void SetText(string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException();
            }

            string encoding = GetTransferEncoding();

            if (encoding == null)
            {
                encoding = MimeConst.Encoding7Bit;
                SetTransferEncoding(encoding);
            }
            MimeCode aCode = MimeCodeManager.Instance.GetCode(encoding);

            aCode.Charset = GetCharset();
            mContent      = aCode.EncodeFromString(text) + "\r\n";

            SetContentType("text/plain");
            SetCharset(aCode.Charset);
        }