item.HasAttachments为true,但集合中没有附件 [英] item.HasAttachments is true but no attachments in collection

查看:102
本文介绍了item.HasAttachments为true,但集合中没有附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检索&从许多邮件项目中复制附件.问题是,即使属性HasAttachment为true,每个邮件项目的集合也为空.

I need to retrieve & copy attached files from a number of mail items. Problem is each mail item's collection is empty, even though the property HasAttachment is true.

检索邮件项目后,是否需要以某种方式加载每个邮件项目的附件链接?

Do I need to load each mail item's attachment colloection somehow after the mail item is retrieved?

以下代码吐出异常索引超出范围":

The following code spits out the exception "index is out of range.":

FindItemsResults<Item> findResults = service.FindItems(
                WellKnownFolderName.Inbox,
                new ItemView(1));

foreach (Item item in findResults.Items)
{
    if (item.HasAttachments && item.Attachments[0] is FileAttachment)
    {
         //Do stuff
    }
}

推荐答案

继续解决方案; item.Load().我认为这是合乎逻辑的,因为在不需要时,轻量级应用程序可能对收集大量附件不感兴趣.

Fell upon the solution; item.Load(). I guess it's logical since a light application might not be interested in collecting heavy attachments when not needed.

这篇关于item.HasAttachments为true,但集合中没有附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆