Lumisoft IMAP 附件已保存 0 字节
我正在尝试使用 Lumisoft 库通过 .NET c# 中的 IMAP 协议保存附件。问题是文件已下载并可以保存,但文件大小为0B。
附件由 IMAP_Fetch_DataItem_Rfc822()
获取。变量 mail
是从流解析的消息: var mail = Mail_Message.ParseFromStream(stream);
foreach (var att in mail.Attachments)
{
if (att.ContentType.Type == "image")
{
try
{
var fPath = Path.Combine(dirPath, att.ContentType.Param_Name);
if (!File.Exists(fPath))
{
Stream data = ((MIME_b_SinglepartBase)att.Body).GetDataStream();
using (FileStream fs = File.Create(fPath))
{
LumiSoft.Net.Net_Utils.StreamCopy(data, fs, 4096);
}
}
Console.WriteLine("Storing image attachment into: " + fPath);
...
I am trying to save an attachment via IMAP protocol in .NET c#, using Lumisoft library. The problem is that the file is downloaded and can be saved, but it's filesize is 0B.
Attachment is fetched by IMAP_Fetch_DataItem_Rfc822()
. Variable mail
is message parsed from stream: var mail = Mail_Message.ParseFromStream(stream);
foreach (var att in mail.Attachments)
{
if (att.ContentType.Type == "image")
{
try
{
var fPath = Path.Combine(dirPath, att.ContentType.Param_Name);
if (!File.Exists(fPath))
{
Stream data = ((MIME_b_SinglepartBase)att.Body).GetDataStream();
using (FileStream fs = File.Create(fPath))
{
LumiSoft.Net.Net_Utils.StreamCopy(data, fs, 4096);
}
}
Console.WriteLine("Storing image attachment into: " + fPath);
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要关闭
Stream data
:You need to close
Stream data
:Lumisoft 解析器似乎无法正确解码附件。
您确定下载后附件大小大于零吗?
不幸的是,LumiSoft 有很多错误,您可以考虑使用商业替代品,
这是我的产品:http://www.lesnikowski.com/mail/
It seems that the Lumisoft parser did not decode attachment correctly.
Are you sure the attachment size after download is more that zero?
LumiSoft unfortunately is pretty buggy, you may consider using commercial alternative,
here's my product: http://www.lesnikowski.com/mail/