我在windows窗体中做了一个获取邮件附件的方法,下面是代码,但是问什么没有成功啊
string path = "";
//获取附件
foreach (MimeEntity entry in m.Attachments)
{
string fileName = entry.ContentDisposition_FileName; //获取文件名称
path = "E:\\jmail\\WindowsFormsApplication1\\Attch\\" + fileName;
if (File.Exists(path))
{
Random random = new Random();
int newfile = random.Next(1, 100000);
path = "E:\\jmail\\WindowsFormsApplication1\\Attch\\Attch" + newfile.ToString();
Directory.CreateDirectory(path);
path += "\\" + fileName;
}
byte[] data = entry.Data;
FileStream pFileStream = null;
pFileStream = new FileStream(path, FileMode.Create);
pFileStream.Write(data, 0, data.Length);
pFileStream.Close();
}
慕丝7291255
慕森卡