小编Mr *_*rno的帖子

.Net Core 3.1 迁移后 C# Exchange Web 服务附件保存不起作用

希望是一个非常简单的。我将一个应用程序.net-core.net使用EWS. 除了进行大量交互异步之外,所有似乎都可以正常工作而无需任何更改。除了从电子邮件下载附件。在调试和使用对象检查器时,FileAttachment对象存在并且对象属性/大小看起来正是我所期望的。的FileAttachmentLoad(string outputPath) 创建一个文件,但是,该文件的内容大小为 0KB。所以外壳已经创建,但没有数据流入其中。可能我错过了一些明显的东西,但明显的东西正在逃避我。尝试使用流和输出路径方法,结果相同。该功能在.net框架版本中仍然可以正常工作。任何想法非常感谢?

                foreach (EmailMessage email in orderedList)
                {

                    EmailMessage message = await EmailMessage.Bind(_service, email.Id, new PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.Attachments));

                    if (email.HasAttachments)
                    {
                        foreach (Attachment attachment in message.Attachments)
                        {
                            bool getFile = false;

                            if (attachment is FileAttachment)
                            {
                                FileAttachment fileAttachment = attachment as FileAttachment;

                                if (!string.IsNullOrEmpty(filename) && fileAttachment.Name.StartsWith(filename))
                                {
                                    getFile = true;
                                }
                                else if (string.IsNullOrEmpty(filename))
                                {
                                    getFile = true;
                                }

                                if (getFile)
                                {

                                    //var response …
Run Code Online (Sandbox Code Playgroud)

c# exchangewebservices asp.net-core-3.1

7
推荐指数
1
解决办法
269
查看次数

标签 统计

asp.net-core-3.1 ×1

c# ×1

exchangewebservices ×1