为了账号安全,请及时绑定邮箱和手机立即绑定

收邮件时获取附件的问题

收邮件时获取附件的问题

富国沪深 2018-12-06 21:37:04
我在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();                        }
查看完整描述

4 回答

?
慕丝7291255

TA贡献1859条经验 获得超6个赞

调试一下出什么异常呢?

查看完整回答
反对 回复 2019-01-21
?
慕森卡

TA贡献1806条经验 获得超8个赞

检查一下路径

查看完整回答
反对 回复 2019-01-21
  • 4 回答
  • 0 关注
  • 368 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信