1

我正在使用 Exchange Web Services v1 从用户邮箱中提取未读电子邮件,如下所示:

        //get exchange service
        ExchangeServiceBinding exchangeService = new ExchangeServiceBinding();
        exchangeService.Credentials = credentials; //LAN credentials of user
        exchangeService.Url = URL; // http://myserver.com/ews/exchange.asmx

        //REturn all properties
        FindItemType findType = new FindItemType();
        findType.Traversal = ItemQueryTraversalType.Shallow;
        findType.ItemShape = new ItemResponseShapeType();
        findType.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;

        //Only search the inbox
        DistinguishedFolderIdType[] foldersToSearch = new DistinguishedFolderIdType[1];
        foldersToSearch[0] = new DistinguishedFolderIdType();
        foldersToSearch[0].Id = DistinguishedFolderIdNameType.inbox;
        findType.ParentFolderIds = foldersToSearch;

        //Only unread emails
        RestrictionType restriction = new RestrictionType();
        IsEqualToType isEqualTo = new IsEqualToType();
        PathToUnindexedFieldType pathToFieldType = new PathToUnindexedFieldType();
        pathToFieldType.FieldURI = UnindexedFieldURIType.messageIsRead;

        //Not IsRead
        FieldURIOrConstantType constantType = new FieldURIOrConstantType();
        ConstantValueType constantValueType = new ConstantValueType();
        constantValueType.Value = "0";
        constantType.Item = constantValueType;
        isEqualTo.Item = pathToFieldType;
        isEqualTo.FieldURIOrConstant = constantType;

        restriction.Item = isEqualTo;

        findType.Restriction = restriction;

        FindItemResponseType findResponse = exchangeService.FindItem(findType);
        ResponseMessageType[] responseMessType = findResponse.ResponseMessages.Items;

        List<ItemIdType> unreadItemIds = new List<ItemIdType>();

现在我想从通用邮箱中查找电子邮件。

我将如何指定要从中提取电子邮件的邮箱?

4

0 回答 0