<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gokulsusan</title>
    <description>The latest articles on DEV Community by Gokulsusan (@gokulsusan_8de3e434b605e3).</description>
    <link>https://dev.to/gokulsusan_8de3e434b605e3</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1730046%2F93c0d1d0-ae76-415f-b01d-a5b5359bd479.jpg</url>
      <title>DEV Community: Gokulsusan</title>
      <link>https://dev.to/gokulsusan_8de3e434b605e3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gokulsusan_8de3e434b605e3"/>
    <language>en</language>
    <item>
      <title>Unable to get the emails from outlook using this method (using graph api)</title>
      <dc:creator>Gokulsusan</dc:creator>
      <pubDate>Thu, 04 Jul 2024 13:44:15 +0000</pubDate>
      <link>https://dev.to/gokulsusan_8de3e434b605e3/unable-to-get-the-emails-from-outlook-using-this-method-using-graph-api-3pd0</link>
      <guid>https://dev.to/gokulsusan_8de3e434b605e3/unable-to-get-the-emails-from-outlook-using-this-method-using-graph-api-3pd0</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/// &amp;lt;summary&amp;gt;
/// Initializes a new instance of &amp;lt;see cref="Office365MailServiceClient"/&amp;gt;.
/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name="connectionParams"&amp;gt;Connection string as a key value pair.&amp;lt;/param&amp;gt;
public Office365MailServiceClient(Dictionary&amp;lt;string, string&amp;gt; connectionParams)
{
    this.graphAuthenticatorV1 = new MSGraphAuthenticator(connectionParams, MSGraphAuthenticator.GraphAPIVersion.v1);
    this.graphClientV1 = this.graphAuthenticatorV1.GetAuthenticatedClient();
}

      private GraphServiceClient graphClientV1;

/// &amp;lt;summary&amp;gt;
/// Gets the mail folder name by id.
/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name="parentFolderId"&amp;gt;Parent Folder Id.&amp;lt;/param&amp;gt;
/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
public string GetMailFolderNameById(string parentFolderId)
 =&amp;gt; graphClientV1.Me.MailFolders[parentFolderId].Request().GetAsync().Result?.DisplayName ?? string.Empty;


public List&amp;lt;Message&amp;gt; GetAllMails()
{
    List&amp;lt;Message&amp;gt; mails = new List&amp;lt;Message&amp;gt;();
    //var result = graphClientV1.Me.Messages.Request().GetAsync();
    //IUserMessagesCollectionPage currentPage = result.Result;
    IUserMessagesCollectionPage currentPage =  graphClientV1.Me.Messages.Request().GetAsync().Result;
    while (currentPage != null)
    {
        foreach (var mail in currentPage)
        {
            try
            {
                mails.Add(mail);
            }
            catch (Exception) { }
        }
        currentPage = (currentPage.NextPageRequest != null) ? currentPage.NextPageRequest.GetAsync().Result : null;
    }
    return mails;
}

getting this error:

   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)


can anyone help me to get resolve this method?
-Thanks in advance.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
  </channel>
</rss>
