【问题标题】:EWS Displays Emails very slowEWS 显示电子邮件非常慢
【发布时间】:2019-10-10 21:11:54
【问题描述】:

我在我的应用程序代码中使用 Exchange 服务在应用程序 UI 上显示电子邮件列表。但是,它能够检索电子邮件列表。但是显示所有设置需要很长时间。如果我减少要显示的电子邮件数量,则显示时间会更少。

public static List<EmailMsg> GetEmailListInFolder(string folderName)
    {
        var folderId = GetFolderId(folderName);
        var service = GetExchangeService();

        if (folderId != null)
        {
            var emails = new List<EmailMsg>();
            var count = 0;
            var findResults = service.FindItems(folderId, new ItemView(100));

            foreach (var item in findResults.Items)
            {
                var emailPropertySet = new PropertySet(
                    BasePropertySet.FirstClassProperties,
                    new PropertyDefinitionBase[]{
                            new ExtendedPropertyDefinition(4115, MapiPropertyType.Binary)
                    });

                var message = EmailMessage.Bind(service, item.Id, emailPropertySet);

                emails.Add(new EmailMsg(folderName, count++, item.Id.UniqueId, message.Subject, message.DateTimeReceived.ToString("yyyy-MMM-dd HH:mm:ss"), ""));
            }
            return emails;
        }

        return null;
    }

当我调试代码并发现在此行上需要几秒钟才能继续下一行。

var message = EmailMessage.Bind(service, item.Id, emailPropertySet);

请给我建议一种方法来减少我的电子邮件项目的加载时间。谢谢

【问题讨论】:

  • 为了找出导致绑定速度变慢的原因,请枚举emailPropertySet 并一次仅使用其中一个来对绑定进行基准测试。我打赌你正在加载大附件。
  • 相关:stackoverflow.com/questions/33898269/…,如果不是骗人的

标签: c# asp.net .net exchange-server exchangewebservices


【解决方案1】:

您将返回所有BasePropertySet.FirstClassProperties
您可能需要考虑将其更改为只返回您需要的属性。

来自msdn 的 FirstClassProperties 列表:

Id
ParentFolderId
ItemClass
Subject
Sensitivity
Body
Attachments
DateTimeReceived
Size
Categories
Importance
InReplyTo
IsSubmitted
IsDraft
IsFromMe
IsResend
IsUnmodified
InternetMessageHeaders
DateTimeSent
DateTimeCreated
AllowedResponseActions
ReminderDueBy
IsReminderSet
ReminderMinutesBeforeStart
DisplayCc
DisplayTo
HasAttachments
Culture
EffectiveRights
LastModifiedName
LastModifiedTime
IsAssociated
WebClientReadFormQueryString
WebClientEditFormQueryString
ConversationId
Flag
InstanceKey
EntityExtractionResult
Sender
ToRecipients
CcRecipients
BccRecipients
IsReadReceiptRequested
IsDeliveryReceiptRequested
ConversationIndex
ConversationTopic
From
InternetMessageId
IsRead
IsResponseRequested
ReplyTo
References
ReceivedBy
ReceivedRepresenting

您正在加载附件。为了避免这种大负载,您可以:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-23
    • 1970-01-01
    • 2011-08-07
    • 1970-01-01
    相关资源
    最近更新 更多