public ReceiveMessageDetailsTask(ChannelConfiguration config, IClientInputChannel channel, ChannelMessageHeader header, ChannelFolder folder)
 {
     this.config = config;
     this.channel = channel;
     this.header = header;
     this.folder = folder;
 }
 public ReceiveMessagesTask(ChannelConfiguration config, IClientInputChannel channel, ChannelFolder folder, ReceiveRange range)
     : base(config, channel)
 {
     this.config = config;
     this.channel = channel;
     this.folder = folder;
     this.range = range;
     this.dataService = ClientState.Current.DataService;
 }
        public ReceiveMessagesTask(ChannelConfiguration config, IClientInputChannel channel, ChannelFolder folder, ReceiveRange range)
            : base(config, channel)
        {
            this.config = config;
            this.channel = channel;
            this.folder = folder;
            this.range = range;

            mailbox = VirtualMailBox.Current;
        }
 public void SelectFolder(ChannelFolder folder)
 {
 }
 public EnumerateLabelsFolderTask(ChannelConfiguration config, IClientInputChannel channel, ChannelFolder folder, ReceiveRange range)
     : base(config, channel, folder, range)
 {
 }
 public void SelectFolder(ChannelFolder folder)
 {
     this.folder = folder;
 }
        public void RemoveFromFolder(ChannelMessageHeader message, ChannelFolder folder)
        {
            var client = new ExchangeClient(Hostname, CredentialsProvider);
            var messageId = client.GetMessageId(message.MessageNumber).ItemId;

            client.DeleteMessage(messageId);
        }
        public void MoveToFolder(ChannelMessageHeader message, ChannelFolder folder)
        {
            var client = new ExchangeClient(Hostname, CredentialsProvider);
            var messageId = client.GetMessageId(message.MessageNumber).ItemId;

            client.MoveMessageToFolder(messageId, folder.FolderId);
        }
        public ChannelFolder CreateFolder(string folderName)
        {
            var client = new ExchangeClient(Hostname, CredentialsProvider);
            var folderId = client.CreateFolder(folderName, folders.First(f => f.FolderType == ChannelFolderType.Inbox).FolderId);

            var newFolder = new ChannelFolder(folderId, folderName, ChannelFolderType.Label);

            folders.Add(newFolder);

            return newFolder;
        }
 public EnumerateLabelsFolderTask(List<Message> changed, ChannelConfiguration config, IClientInputChannel channel, ChannelFolder folder, ReceiveRange range)
     : base(config, channel, folder, range)
 {
     this.changed = changed;
 }
        /// <summary>
        /// Gets the nr of items in a given folder
        /// </summary>
        /// <returns></returns>
        public long GetNrItemsInFolder(ChannelFolder folder)
        {
            var binding = ChannelHelper.BuildChannel(hostname, username, password);

            var findItemRequest = new FindItemType { Traversal = ItemQueryTraversalType.Shallow };
            var itemProperties = new ItemResponseShapeType { BaseShape = DefaultShapeNamesType.AllProperties };
            findItemRequest.ItemShape = itemProperties;

            var folderIdArray = new DistinguishedFolderIdType[2];
            folderIdArray[0] = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.inbox };

            findItemRequest.ParentFolderIds = folderIdArray;

            FindItemResponseType findItemResponse = binding.FindItem(findItemRequest);

            // Determine whether the request was a success.
            if (findItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Error)
                throw new Exception(findItemResponse.ResponseMessages.Items[0].MessageText);

            var responseMessage =
                (FindItemResponseMessageType) findItemResponse.ResponseMessages.Items[0];

            var mailboxItems = (ArrayOfRealItemsType)responseMessage.RootFolder.Item;

            if (mailboxItems.Items == null) return 0;

            return mailboxItems.Items.Length;
        }
        /// <summary>
        /// Gets a list of all the items in the mailbox with all their properties.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<MessageType> GetHeaders(ChannelFolder folder)
        {
            var binding = ChannelHelper.BuildChannel(hostname, username, password);

            var findItemRequest = new FindItemType { Traversal = ItemQueryTraversalType.Shallow };
            var itemProperties = new ItemResponseShapeType { BaseShape = DefaultShapeNamesType.AllProperties };

            findItemRequest.ItemShape = itemProperties;
            findItemRequest.ParentFolderIds = new BaseFolderIdType[] { new FolderIdType { Id = folder.FolderId } };

            FindItemResponseType findItemResponse = binding.FindItem(findItemRequest);

            foreach (FindItemResponseMessageType responseMessage in findItemResponse.ResponseMessages.Items)
            {
                if (responseMessage.ResponseClass == ResponseClassType.Success)
                {
                    ArrayOfRealItemsType mailboxItems = (ArrayOfRealItemsType) responseMessage.RootFolder.Item;

                    if (mailboxItems.Items == null)
                        yield break;

                    foreach (MessageType inboxItem in mailboxItems.Items)
                        yield return inboxItem;
                }
            }
        }