Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# S22.Imap无法处理作为附件添加的.msg(Outlook邮件项目)文件_C#_Asp.net Core_Imap - Fatal编程技术网

C# S22.Imap无法处理作为附件添加的.msg(Outlook邮件项目)文件

C# S22.Imap无法处理作为附件添加的.msg(Outlook邮件项目)文件,c#,asp.net-core,imap,C#,Asp.net Core,Imap,我正在使用s22.Imap从服务器获取电子邮件及其附件。我能够使用下面的代码编写所有附件,除了.msg文件附件 这是一个ASP.NET Core 2.1/C应用程序,其中以下代码位于邮件实用程序类中 foreach (Attachment attachment in message.Attachments) { byte[] allBytes = new byte[attachment.ContentStream.Length]; int bytesRead = attach

我正在使用s22.Imap从服务器获取电子邮件及其附件。我能够使用下面的代码编写所有附件,除了.msg文件附件

这是一个ASP.NET Core 2.1/C应用程序,其中以下代码位于邮件实用程序类中



foreach (Attachment attachment in message.Attachments)
{
    byte[] allBytes = new byte[attachment.ContentStream.Length];
    int bytesRead = attachment.ContentStream.Read(allBytes, 0, (int)attachment.ContentStream.Length);
    string destinationFile = @"C:\\Path\\" + attachment.Name;
    BinaryWriter writer = new BinaryWriter(new FileStream(destinationFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None));
    writer.Write(allBytes);
    writer.Close();
}

每次S22.Imap返回不同的文件名和扩展名,如“dqcbws10.pnx”。是否有任何特定的方法来处理S22.IMAP返回的.msg文件


我帖子中的C代码能够处理所有其他附件格式,如.xls、.xlsx、.zip、.dat。但是当通过S22.IMAP库检索到类似SampleMessage.msg的.msg文件时,它会被转换为类似“dqcbws10.pnx”的文件,而不是SampleMessage.msg。需要做什么才能将其转换为“SampleMessage.msg”。通过谷歌搜索,它提出了类似rfc822格式的建议。我需要关于如何将“dqcbws10.pnx”转换为“SampleMessage.msg”的指针。

您可以用任何方式处理它们。这里的问题是什么?你是在问为什么发件人没有建议文件名吗?发件人不必为附件命名。嗨,阿恩特,谢谢你抽出时间。我已经编辑了我的帖子来添加更多信息。也许我看到了。。。没有实际的转换,只是文件名的选择。您可以重命名该文件。