没见过有现成的处理附件的类,当时作的时候是把邮件读出来的时候自己判断有没有附件,if有,先取得附件的文件名称,然后在服务器上建这个文件,然后把附件的内容写进去,对于文本类的附件处理没有问题,其他类型的文件没有测试过。
private void processAtt(string info)
{
int index = -1;
string encodeTag = "Content-Transfer-Encoding: ";
string attachTag = "Content-Disposition: attachment";
string fileNametag ="filename=";
int encodeIndex;
encodeIndex = info.IndexOf(encodeTag);
int nextLine;
while(encodeIndex != -1)
{
nextLine = info.IndexOf("\n",encodeIndex); 
if((index =info.IndexOf(attachTag,nextLine,attachTag.Length+2)) != -1)
{
this.attEncode = info.Substring(encodeIndex + encodeTag.Length,nextLine-encodeIndex - encodeTag.Length);
int fileNameIndex = info.IndexOf(fileNametag,index);
int from = fileNameIndex+fileNametag.Length+1;
int end = info.IndexOf("\"",from);
// int end = info.IndexOf("=_NextPart"",from);
this.attIndex = end + 1;
this.fileName = info.Substring(from,end-from);
return;
}
encodeIndex = info.IndexOf(encodeTag,encodeIndex + encodeTag.Length);
}
}