コード例 #1
0
        /// <summary>
        /// 生成一个不重复分隔
        /// </summary>
        /// <returns>返回字符串表达形式</returns>
        internal static string MakeBoundary()
        {
            string Rueslt = "Boundary-=_Next.";
            //加入不重复时间
            Random rd = new Random();

            Rueslt += Coding.Base64Encode(DateTime.Now.ToString("yMMddHHmmssffff") + rd.Next(1, 30).ToString(), Encoding.ASCII);
            return(Rueslt);
        }
コード例 #2
0
        /// <summary>
        /// 生成一个邮件ID
        /// </summary>
        /// <returns>返回邮件ID的字符串表达形式</returns>
        internal static string MakeMessageID()
        {
            Random rd     = new Random();
            string Rueslt = "Message-ID: <";

            Rueslt += Coding.Base64Encode(DateTime.Now.ToString("yMMddHHmmssffffff") + rd.Next(1, 30).ToString(), Encoding.ASCII);          //加入邮件ID的时间表达型式,以此表示ID不重复
            Rueslt += string.Format("@{0}>", System.Net.Dns.GetHostName());
            return(Rueslt);
        }
コード例 #3
0
        /// <summary>
        /// 进行Html文本内容的读取
        /// </summary>
        /// <returns>返回所生成的Html文本内容数据</returns>
        internal protected virtual string ReadHtml()
        {
            if (string.IsNullOrEmpty(this.Html))
            {
                return("");
            }

            StringBuilder sb = new StringBuilder();

            //
            sb.Append("--");
            sb.Append(this.Boundary);
            sb.Append(MailCommon.NewLine);              //分隔完成

            sb.Append("Content-Type: text/html;");
            sb.Append(MailCommon.NewLine);
            sb.AppendFormat("   charset=\"{0}\" ", this.SetCharset);
            sb.Append(MailCommon.NewLine);

            sb.AppendFormat("Content-Transfer-Encoding: ");

            if (this.EncodeType == MailEncodeType.BASE64)
            {
                sb.Append("base64");
                sb.Append(MailCommon.NewLine + MailCommon.NewLine);

                sb.Append(Coding.Base64Encode(this.Html, this.Charset));

                sb.Append(MailCommon.NewLine + MailCommon.NewLine);

                return(sb.ToString());
            }

            //qp  --  quoted-printable"
            sb.Append("quoted-printable");
            sb.Append(MailCommon.NewLine + MailCommon.NewLine);
            sb.Append(Coding.EncodeQuotedPrintable(this.Html, this.Charset));
            sb.Append(MailCommon.NewLine + MailCommon.NewLine);

            return(sb.ToString());
        }
コード例 #4
0
 /// <summary>
 /// 进行BASE64头的编码
 /// </summary>
 /// <param name="Src">要进行编码的串</param>
 /// <param name="enc">编码类型</param>
 /// <param name="Charset">文件字符集</param>
 /// <returns>返回编码后的串</returns>
 internal static string EncodBase64Head(string Src, Encoding enc, string Charset)
 {
     return("=?" + Charset + "?B?" + Coding.Base64Encode(Src, enc) + "?=");
 }