Thank you for your response. Of course, when I read your response and saw you reference a 404 error, I hit myself on the head. I’m getting a 401 error, not a 404 error. So I AM reaching the server, I just dont have the proper sign in information being sent. I’m not sure why that is because I am using the same email address and password that I use to log into my microsoft account on-line. This is the code that I am now trying to execute:
Thank you for the additional information.
Most likely your problem is that Microsoft has recently discontinued support for Basic Authentication on client apps. Try using Modern Authentication. We have the doc and the same blog article on how to do this.
Also, I have attached a test app using Modern Authentication: EWSModernAuthenticationApp.zip (3.4 KB)
All you have to do is specify your credentials there.
@DmitryS,
Thank you for this information! I read through the blog and had to log into the Azure portal to register my app (which I did). I got the app id, tenantID, and client secret. I assume the username will be “jonathan.small” since my email address is jonathan.small@intersoftassociates.com.
I populated the fields in the appsettings.json file as instructed and ran the application with a break point on this line:
if (accessToken != null)
I hit the breakpoint and added accessToken to the watch and I can see an accessToken value so I know I connected to microsoft and retrieved the token. Then I clicked on the continue button and I get this screen:
I ran the application a second time and once I hit the breakpoint, I stepped through the code. The error screen that I provided is generated as a result of trying to execute this line of code:
using var client = EWSClient.GetEWSClient("https://outlook.office365.com/EWS/Exchange.asmx", credentials);
Thanks. I made this change in my VS settings. I also found a page on the Azure active directory admin page which shows my project owners. It tells me that my user name is something other than what I thought. So I changed the value in the appsettings.json file to the value that Azure says and I reran the code. Now I get a “The request failed with HTTP status 403: Forbidden” message when trying to execute
using var client = EWSClient.GetEWSClient("https://outlook.office365.com/EWS/Exchange.asmx", credentials);
Now I’m a bit confused. I was able to retrieve an access token, so that implies to me that I have provided the correct information in the appsettings.json file. Otherwise, I would not get back an access token. So who would be forbidding me access when trying to connect to the EWS/Exchange.asmx?
Maybe I’m going about this the wrong way. My goal is to use Aspose to sync my outlook calendar to my google calendar. Will the Aspose.Email product provide me with the necessary tools to accomplish this?
Now I get a “The request failed with HTTP status 403: Forbidden” message when trying to execute
Using Modern Auth requires attention when setting up the app on the Azure active directory page.
We provide only client-side functionality and cannot control the server-side settings.
If you are using a confidential client, make sure that the permission is of the Application type and not delegated. Set the full_access_as_app. This will give access to the mailbox and will require administrator approval first. Are you an administrator? All application-level permissions require administrator approval 1.png (28.2 KB).
My goal is to use Aspose to sync my outlook calendar to my google calendar. Will the Aspose.Email product provide me with the necessary tools to accomplish this?
Perhaps the following information will be helpful to you.