Unauthorized error in running Exchange Server Examples

Hi there, I am trying the example of ListingMessagesFromFolders class and having the error in the following statement:

 IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

Please advise. Thank you!

Yvonne

@yvonne1,

We have tested this at our end with the latest version of Aspose.Email for .NET 17.7 and are unable to face any such problem as you have mentioned. Following test account and code sample has been used to test this. Please try it at your end and let us know your feedback.

Sample Code

IEWSClient client = EWSClient.GetEWSClient(“https://outlook.office365.com/ews/exchange.asmx”, “Userone@AsposeJul2017.onmicrosoft.com”, “Aspose1234”);

ExchangeMessageInfoCollection msgs = client.ListMessages(client.MailboxInfo.InboxUri);

Console.WriteLine(msgs.Count);

Thanks for the prompt reply, Kashif! I have tried the sample code you provided but it does work neither. I then went on to the web site using the credential in the sample code (and making sure it’s outside of our corporation network). I cannot sign in. I could show you the picture of the screenshot but there is no way to post a pic here.

Any advice would be greatly appreciated!

Thanks again,
Yvonne

@yvonne1,

We are sorry for the confusion. The password is “Aspose1234” that should work with the account we have provided in our earlier post. Please try it at your end and let us know if we can be of any additional help to you.

Thank you for the correction, which has worked in my IDE :slightly_smiling_face:
I guess there is nothing in it so I’ve got a 0 count sent back. Is it possible to put some testing email items in the Exchange server so that we could try the functions in the sample code? As you can see I am new to the system and trying to make sense to the tool.

Many thanks!
Yvonne

@yvonne1,

Yes, the Inbox of the account has no emails and that is why you get a zero count. We have a complete set of code samples that you can experiment with using the IEWSClient and Exchange server. Please have a look at our documentation section, Working with Exchange EWS client, for further samples in this regard. You can write to us any time for your queries related to any functionality.

PS: If you are not using a license in your application, you will be limited by evaluation limitations of the API. In order to test the API without evaluation limitations, you can get a 30-day temporary license free of cost.

Thank you Kashif! I have started with your document and the sample code. Now I do have another question:)

In my IDE there is an error saying 'The name ‘ListExchangeServerMessages’ does not exist in the current context . This is in the Exchange Server Examples region.
But I can see the class ListExchangeServerMessages existing in the Class view, as well as in the Exchange_WebDav folder in the solution browser.

Please advise!

Many thanks!
Yvonne

@yvonne1,

Could you please point us to this example where “ListExchangeServerMessages” is used? We can’t find it in the documentation section we have mentioned above. You can use ListMessages method with IEWSClient to get the list of messages from Exchange server. Please note that WebDav protocol is only supported for Exchange Server 2003 and 2007 and you can use the API’s ExchangeClient with these servers only. With 2007 and onwards, the Exchange Web Service (EWS) protocol is supported and you can use the API’s IEWSClient for connecting to these servers. Please feel free to post us with your inquiry, if any, in this regard.

Hi Kashif,
It’s in the Exchange Server Examples region. Yeah, you are right the document didn’t mention this method. I was just going through some samples and hit this problem. Being a bit rusty with C# it took me a while to figured it out: the WebDav folder was not using in RunExamples.

Thanks for your explanation about WebDav…I did have wondered what’s the difference between EWS and WebDav. Now I guess that the WebDav folder probably not being referenced to on purpose, but because the samples are mixed together in the Exchange Server Examples region, it’s a bit confusing. It would be nice if all the WebDav samples could be separated and have its own region. :slight_smile:

Again, thanks for your prompt response!
Yvonne

@yvonne1,

We’ll update the examples in order for these to be more understandable and as per our online documentation. Please feel free to write to us if you have any further query related to working with the API.

Thank you for the prompt support, guys! Will talk soon:)

@yvonne1,

You are welcome and please feel free to write to us for any further query related to the API.