public void Save()
{
if(_path != null)
{
if(_path != "" && !Directory.Exists(_path))
{
throw new DirectoryNotFoundException(_path);
}
}
if(_header_list.Count != _body_list.Count && _body_list.Count > 0)
{
throw new FormatException();
}
string read_body;
string read_header;
string keep_id = "";
int id_no;
SetHeaderSize();
_subject = new StringBuilder(_header_size);
_date = new StringBuilder(_header_size);
_from = new StringBuilder(_header_size);
_header = new StringBuilder(_header_size);
_body = new StringBuilder(GetBodySize());
Options.FileNameMax = MaxPath;
_filename = new StringBuilder(MaxPath);
for(int no = 0 ; no < _header_list.Count ; no++)
{
if(no < _body_list.Count)
{
read_body = (string)_body_list[no];
}
else
{
read_body = "";
}
read_header = (string)_header_list[no];
if(no == 0)
{
id_no = GetId(read_header);
if(id_no > 1) {
throw new nMailException("Save", ErrorInvalidNo);
}
keep_id = PartId;
_attachment_flag = true;
_err = AttachmentFileFirst(_temp, _subject, _date, _from, _header, _body, _path, _filename, read_header, read_body);
}
else
{
if(GetId(read_header) != no + 1 || keep_id != PartId) {
throw new nMailException("Save", ErrorInvalidNo);
}
_err = AttachmentFileNextVB(_temp, _subject, _date, _from, _header, _body, _path, _filename, read_header, read_body);
}
if(_err < 0 && _err != ErrorPartial)
{
throw new nMailException("Save", _err);
}
}
if(_filename.Length > 0)
{
_filename_list = _filename.ToString().Split(Options.SplitChar);
}
else
{
_filename_list = null;
}
if(Options.SaveHtmlFile == Options.SaveHtmlFileOn) {
_html_file = new StringBuilder(_header_size);
Pop3GetHeaderField(_html_file, _header.ToString(), "X-NMAIL-HTML-FILE:", _header_size);
}
if(Options.SaveRfc822File != Options.SaveRfc822FileOff) {
_rfc822_file = new StringBuilder(_header_size);
Pop3GetHeaderField(_rfc822_file, _header.ToString(), "X-NMAIL-RFC822-FILE:", _header_size);
}
AttachmentFileClose(_temp);
_attachment_flag = false;
}