Exemple #1
0
        public async Task <List <Message> > ListSentMessages(string userid, string fparam1)
        {
            List <ResultsItem> items = new List <ResultsItem>();

            List <QueryOption> options = new List <QueryOption>()
            {
                new QueryOption("filter", "folder ne null"),
                new QueryOption("select", "id,name,webUrl")
            };

            IMailFolderMessagesCollectionPage messages = await _graphClient.Users[userid].MailFolders.SentItems.Messages.Request().Top(100).GetAsync();

            if (string.IsNullOrEmpty(fparam1))
            {
                return(messages.ToList());
            }
            return(messages.ToList().Where(i => i.Subject.ToLower().Contains(fparam1)).ToList <Message>());
        }
Exemple #2
0
        /// <summary>
        /// MEthod for fetching the Inbox messages
        /// </summary>
        /// <param name="userid">Messages from which user</param>
        /// <param name="searchparam1">filter parameter for the subject</param>
        /// <returns></returns>
        public async Task <List <Message> > ListInboxMessages(string userid, string searchparam)
        {
            //List<ResultsItem> items = new List<ResultsItem>();

            IMailFolderMessagesCollectionPage messages = await _graphClient.Users[userid].MailFolders.Inbox.Messages.Request().Top(100).GetAsync();

            //List<Message> fmsgs = messages.ToList<Message>().Where(i => i.Subject.ToLower().Contains(searchparam)).ToList<Message>();
            //if (messages?.Count > 0)
            //{
            //    foreach (Message message in messages)
            //    {
            //        items.Add(new ResultsItem
            //        {
            //            Subject = message.Subject,
            //            Id = message.Id
            //        });
            //    }
            //}
            if (string.IsNullOrWhiteSpace(searchparam))
            {
                return(messages.ToList());
            }
            return(messages.ToList().Where(i => i.Subject.ToLower().Contains(searchparam)).ToList <Message>());
        }