We are using Microsoft GraphAPI to read emails from the inbox, and we now are using the Aspose.Email v25.1.
Code snippet used:
static string FromEmail = “”;
static void Main(string[] args)
{
-
Console.WriteLine(“Microsoft Graph API POC Started”);*
-
-
AccessParameters accessParams = new AccessParameters()*
-
{*
-
TenantId = "<GraphAPI App TenantID>",*
-
ClientId = "<GraphAPI App ClientID>",*
-
ClientSecret = "<GraphAPI App Client Secret>",*
-
UserId = FromEmail*
-
};*
-
SetAsposeLicense();*
-
GraphTokenProvider tokenProvider = new GraphTokenProvider(accessParams); // As per samples provided by Aspose*
-
using (IGraphClient client = GraphClient.GetClient(tokenProvider, accessParams.TenantId))*
-
{*
-
client.Resource = ResourceType.Users;*
-
client.ResourceId = accessParams.UserId;*
-
var folders = client.ListFolders(); //Getting Error here*
-
}*
}
The GraphAPI App is registered with the Mail.Read and Mail.Send Application permissions.
We are getting errors when trying to get the folder list mentioned in the code snippet.
The same code snippet worked in version 24.1, but thereafter in other versions it is not working.
Please fix the issue as we are unable to upgrade version because of the above problem.
@RamanaReddyC
It seems that you are encountering issues with the ListFolders()
method when using Aspose.Email v25.1 with Microsoft Graph API. Since the same code worked in version 24.1, it is possible that there have been changes or regressions in the newer version that are affecting the functionality.
Here are a few steps you can take to troubleshoot and potentially resolve the issue:
-
Check Permissions: Ensure that the application permissions for Mail.Read and Mail.Send are correctly configured in the Azure portal. Sometimes, permissions may not propagate correctly, or additional permissions may be required.
-
Review Changes in Version 25.1: Look into the release notes or change logs for Aspose.Email v25.1 to identify any breaking changes or modifications related to the Graph API client. This can provide insights into what might have changed between versions.
-
Error Handling: Implement error handling around the ListFolders()
call to capture and log the specific error message. This can help in diagnosing the issue more effectively.
-
Testing with a Minimal Example: Create a minimal example that only attempts to list folders. This can help isolate the problem and determine if it is related to your specific implementation or a broader issue with the library.
-
Revert to Previous Version: If the issue persists and is critical for your application, consider reverting to version 24.1 until a fix or workaround is identified in the newer version.
If you continue to experience difficulties, I recommend reaching out to the Aspose support team or checking the Aspose forums for similar issues reported by other users. They may have additional insights or solutions based on their experiences.
If you have any specific error messages or logs, feel free to share them for more targeted assistance.
Hello @RamanaReddyC,
Welcome to our support forum!
What exception are you getting when calling client.ListFolders()?
Thank you.
Aspose.Email.AsposeBadServerResponceException: 'Server error Status: ErrorAccessDenied
Description: Access is denied. Check credentials and try again.
Details:
–>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
GET: https://graph.microsoft.com/v1.0/users/emailID_masked/contactfolders
Authorization: Bearer eyJ0eXAiiJKV1QiLCJub25jZSI6IjktU0czaC1ZWmc3VDhVdlIzb2pPbWJkRVY4ZEl6WlpXZ3dUaUdpUVVHNG8iLCJhbGciOiJSUzI1NiIsIng1dCI6IllUY2VPNUlKeXlxUjZqekRTNWlBYnBlNDJKdyIsImtpZCI6IllUY2VPNUlKeXlxUjZqekRTNWlBYnBlNDJKdyJ9.eyJhdWQiOiJodHRwczovL2dyYXBoLm1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8zY2E4ZmY3ZC1hY2RhLTRmNDItYjhkNS1hNGY1ODdkZjcxMDEvIiwiaWF0IjoxNzM4ODQ4NDIyLCJuYmYiOjE3Mzg4NDg0MjIsImV4cCI6MTczODg1MjMyMiwiYWlvIjoiazJSZ1lQaDVMZW1oWVFhWHpKR3Z1MDd4Y3luZUJBQT0iLCJhcHBfZGlzcGxheW5hbWUiOiJHUkFQSSIsImFwcGlkIjoiNDE2YjE2MjctZTFiMS00YWU3LWJmMDctZTBkNzBiOGQ2YTA4IiwiYXBwaWRhY3IiOiIxIiwiaWRwIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvM2NhOGZmN2QtYWNkYS00ZjQyLWI4ZDUtYTRmNTg3ZGY3MTAxLyIsImldHlwIjoiYXBwIiwib2lkIjoiNmM5NmQzZGQtZTg4MS00OWQ2LTllMmQtN2Q3YmMwZWYwN2RkIiwicmgiOiIxLkFYQUFmZi1vUE5xc1FrLTQxYVQxaDk5eEFRTUFBQUFBQUFBQXdBQUFBQUFBQUFERUFBQndBQS4iLCJyb2xlcyI6WyJNYWlsLlJlYWQiLCJNYWlsLlNlbmQiXSwic3ViIjoiNmM5NmQzZGQtZTg4MS00OWQ2LTllMmQtN2Q3YmMwZWYwN2RkIiwidGVuYW50X3JlZ2lvbl9zY29wZSI6IkFTIiwidGlkIjoiM2NhOGZmN2QtYWNkYS00ZjQyLWI4ZDUtYTRmNTg3ZGY3MTAxIiwidXRpIjoia0JYaVIxRkhPVXVWTG5OV1hBOFhBQSIsInZlciI6IjEuMCIsIndpZHMiOlsiMDk5N2ExZDAtMGQxZC00YWNiLWI0MDgtZDVjYTczMTIxZTkwIlsInhtc19pZHJlbCI6IjI0IDciLCJ4bXNfdGNkdCI6MTYwMTg4MzE4Nn0.RjtSf3JAiMKtpC0QH8vlIPVHaIV4B85927cnsTylF6h4PCJ79gv68P0wL76mnB7Xfi-kuue4buyl58T5jHystcha7fc0-xTbDkAYsrt5Wp9dJ0mvla1M-A7VTcYDL1wBaxMsEXf7OZFFW4lHH-i9SEIiUlgzF7Q7eaEg4OGd-ge7hUcn0lg0Ynq3wXu7OJrqnmbHYAKgZCgnL9C1HPgWldz-qO6ZdV_TB_Ah48Ylx7e3KLTffoi1qyTbsbozlghbF1xIFaS54HfYm_vKsQYLmb1_ce4zhpA6tJU_0xOr9agkyuHQXTiGWmsLkdtP5CRsUT6uEH_qV12AI3jPPkfccQ
Accept: application/json
Content-Length: 0
StatusCode: Forbidden
Cache-Control: private
Transfer-Encoding: chunked
Strict-Transport-Security: max-age=31536000
request-id: 371cd03-363d-4eae-bd3-ef46b07680e
client-request-id: 371cd03e-363d-4eae-bd33-ef46bd07680e
x-ms-ags-diagnostic: {“ServerInfo”:{“DataCenter”:“South America”,“Slice”:“E”,“Ring”:“2”,“ScaleUnit”:“002”,“RoleInstance”:“MA1PP0009601”}}
Date: Thu, 06 Feb 2025 13:32:02 GMT
Content-Type: application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8
{“error”:{“code”:“ErrorAccessDenied”,“message”:“Access is denied. Check credentials and try again.”}}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
it is throwing the previously mentioned error as the client.ListFolders() is in turn querying to https://graph.microsoft.com/v1.0/users/emailID-here/**contactfolders**
as we have not given contacts read permission to the GRAPHAPI app. We have only given Mail.Read and Mail.Send.
As mentioned, the code still works for Aspose.Email version 24.1 today also, but it will not work in rest of the versions there after.
@RamanaReddyC,
We have opened the following new ticket in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): EMAILNET-41508
The issue occurred after the addition of contact support because the library does not check for contact permissions by default.
Thank you.
Thanks.
We have raised the same issue using Paid Support before and no one has responded to that issue there and I got a fast response here in the forum so quick.
So pathetic that Aspose Paid support is useless.
@RamanaReddyC,
Thank you for bringing this to our attention.
We will escalate the priority of your ticket to ensure you receive a resolution as soon as possible.