/// <summary> /// The get mime body. /// </summary> /// <param name="messageId"> /// The message id. /// </param> /// <param name="part"> /// The part. /// </param> /// <returns> /// </returns> private ArticleBody GetMIMEBody(string messageId, MIMEPart part) { string line = null; ArticleBody body = null; StringBuilder sb = null; var attachmentList = new ArrayList(); try { NntpUtil.DispatchMIMEContent(this.sr, part, "."); sb = new StringBuilder(); attachmentList = new ArrayList(); body = new ArticleBody { IsHtml = true }; this.ConvertMIMEContent(messageId, part, sb, attachmentList); body.Text = sb.ToString(); body.Attachments = (Attachment[])attachmentList.ToArray(typeof(Attachment)); } finally { if (((NetworkStream)this.sr.BaseStream).DataAvailable) { while ((line = this.sr.ReadLine()) != null && line != ".") { ; } } } return(body); }
/// <summary> /// The get mime body. /// </summary> /// <param name="messageId"> /// The message id. /// </param> /// <param name="part"> /// The part. /// </param> /// <returns> /// </returns> private ArticleBody GetMIMEBody(string messageId, MIMEPart part) { string line = null; ArticleBody body = null; StringBuilder sb = null; var attachmentList = new ArrayList(); try { NntpUtil.DispatchMIMEContent(this.sr, part, "."); sb = new StringBuilder(); attachmentList = new ArrayList(); body = new ArticleBody { IsHtml = true }; this.ConvertMIMEContent(messageId, part, sb, attachmentList); body.Text = sb.ToString(); body.Attachments = (Attachment[]) attachmentList.ToArray(typeof (Attachment)); } finally { if (((NetworkStream) this.sr.BaseStream).DataAvailable) { while ((line = this.sr.ReadLine()) != null && line != ".") { ; } } } return body; }
/// <summary> /// The get normal body. /// </summary> /// <param name="messageId"> /// The message id. /// </param> /// <returns> /// </returns> private ArticleBody GetNormalBody(string messageId) { var buff = new char[1]; string response = null; var list = new ArrayList(); var sb = new StringBuilder(); MemoryStream ms = null; this.sr.Read(buff, 0, 1); int i = 0; Match m = null; while ((response = this.sr.ReadLine()) != null) { if (buff[0] == '.') { if (response == string.Empty) { break; } else { sb.Append(response); } } else { if ((buff[0] == 'B' || buff[0] == 'b') && (m = Regex.Match(response, @"^EGIN \d\d\d (.+)$", RegexOptions.IgnoreCase)).Success) { ms = new MemoryStream(); while ((response = this.sr.ReadLine()) != null && (response.Length != 3 || response.ToUpper() != "END")) { NntpUtil.UUDecode(response, ms); } ms.Seek(0, SeekOrigin.Begin); byte[] bytes = new byte[ms.Length]; ms.Read(bytes, 0, (int) ms.Length); Attachment attach = new Attachment(messageId + " - " + m.Groups[1].ToString(), m.Groups[1].ToString(), bytes); list.Add(attach); ms.Close(); i++; } else { sb.Append(buff[0]); sb.Append(response); } } sb.Append('\n'); this.sr.Read(buff, 0, 1); } var ab = new ArticleBody { IsHtml = false, Text = sb.ToString(), Attachments = (Attachment[])list.ToArray(typeof(Attachment)) }; return ab; }
/// <summary> /// The get normal body. /// </summary> /// <param name="messageId"> /// The message id. /// </param> /// <returns> /// </returns> private ArticleBody GetNormalBody(string messageId) { var buff = new char[1]; string response = null; var list = new ArrayList(); var sb = new StringBuilder(); MemoryStream ms = null; this.sr.Read(buff, 0, 1); int i = 0; Match m = null; while ((response = this.sr.ReadLine()) != null) { if (buff[0] == '.') { if (response == string.Empty) { break; } else { sb.Append(response); } } else { if ((buff[0] == 'B' || buff[0] == 'b') && (m = Regex.Match(response, @"^EGIN \d\d\d (.+)$", RegexOptions.IgnoreCase)).Success) { ms = new MemoryStream(); while ((response = this.sr.ReadLine()) != null && (response.Length != 3 || response.ToUpper() != "END")) { NntpUtil.UUDecode(response, ms); } ms.Seek(0, SeekOrigin.Begin); byte[] bytes = new byte[ms.Length]; ms.Read(bytes, 0, (int)ms.Length); Attachment attach = new Attachment(messageId + " - " + m.Groups[1].ToString(), m.Groups[1].ToString(), bytes); list.Add(attach); ms.Close(); i++; } else { sb.Append(buff[0]); sb.Append(response); } } sb.Append('\n'); this.sr.Read(buff, 0, 1); } var ab = new ArticleBody { IsHtml = false, Text = sb.ToString(), Attachments = (Attachment[])list.ToArray(typeof(Attachment)) }; return(ab); }