您的位置:首页 > 其它

lumisoft会将eml后缀格式的附件给解析成文本,这里保存成文件

2017-02-16 15:35 417 查看
MIME_Entity[] attachments = mime.Attachments;
foreach (MIME_Entity entity in attachments)
{
string fileName = entity.ContentType.Param_Name;
string dir = Server.MapPath("~/d");
string path = Path.Combine(dir, fileName);
if (entity.Body is MIME_b_SinglepartBase)
{
MIME_b_SinglepartBase byteObj = (MIME_b_SinglepartBase)entity.Body;
Stream decodedDataStream = byteObj.GetDataStream();
using (FileStream fs = new FileStream(path, FileMode.Create))
{
LumiSoft.Net.Net_Utils.StreamCopy(decodedDataStream, fs, 4000);
}
}
if (entity.Body is MIME_b_MessageRfc822)
{
MIME_b_MessageRfc822 byteObj = (MIME_b_MessageRfc822)entity.Body;
Mail_Message mm = byteObj.Message;
mm.ToFile(path, null, null);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: