private void ReadHeader(Attachment atch) { string line = ReadLineString(); while (line != null) { line = line.Trim(); // End of header reached if (line == "") { break; } string headerField = line; line = ReadLineString(); while (line != null && (line.StartsWith("\t") || line.StartsWith(" "))) { headerField += line; line = ReadLineString(); } string[] name_value = headerField.Split(new char[] { ':' }, 2); // There must be header field name and value, otherwise invalid header field if (name_value.Length == 2) { atch.AddField(name_value[0], name_value[1]); } } }
public Attachment GetNext() { Attachment atch = new Attachment(); ReadHeader(atch); if (atch.Fields.Count == 0) { return null; } atch.Data = ReadContent(); return atch; }