Exemplo n.º 1
0
        public static async Task <string> ReadMessage(string AccessToken, string userid, string mailfolderid)
        {
            var httpClient = new HttpClient();
            var apiCaller  = new ProtectedApiCallHelper(httpClient);

            getmessages mailmessagedetails = new getmessages();

            var url = $"https://graph.microsoft.com/beta/users/{userid}/mailFolders/{mailfolderid}/messages?filter=startswith(subject,'Output')";

            JObject mailmessage = await apiCaller.CallGetWebApiAndProcessResultASync(url, AccessToken);

            IList <JToken>      mailmessages       = null;
            IList <getmessages> mailmessageresults = null;

            mailmessages = mailmessage["value"].Children().ToList();
            if (mailmessages.Count > 0)
            {
                mailmessageresults = new List <getmessages>();

                foreach (JToken res in mailmessages)
                {
                    mailmessagedetails = res.ToObject <getmessages>();
                    mailmessageresults.Add(mailmessagedetails);
                }
                await DeleteMessage(AccessToken, userid, mailmessagedetails.id);

                return(mailmessagedetails.body.content);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public static async Task <string> GetUserID(string AccessToken, string user)
        {
            #region GetUserID
            var httpClient = new HttpClient();
            var apiCaller  = new ProtectedApiCallHelper(httpClient);

            getuserid userid = new getuserid();
            var       url    = $"https://graph.microsoft.com/beta/users?$select=id&$filter=startswith(displayname, '{user}')";
            JObject   users  = await apiCaller.CallGetWebApiAndProcessResultASync(url, AccessToken);

            IList <JToken> userresults = users["value"].Children().ToList();

            IList <getuserid> usersearchResults = new List <getuserid>();
            foreach (JToken res in userresults)
            {
                userid = res.ToObject <getuserid>();
                usersearchResults.Add(userid);
            }
            return(userid.id);

            #endregion GetUserID
        }