I have an application extracting emails from 'User A', with the email address [email protected]. I use the following code to do so:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
service.UseDefaultCredentials = true;
service.Url = new Uri(ServerName);
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(500));
This works fine if User A is logged in and runs the application.
However, lets say 'User B' has been granted access to User A's inbox and wants to run the same application to extract files from User A's Inbox. How would I change the code above to specify the email account inbox?
I know that I could hardcode the login details of User A when getting the credentials, but ideally I would avoid having hardcoded usernames but instead use the credentials of the user running the application.
This may just be my lack of understanding, but I'm relatively new to .net and very new to EWS. Any pointers would be much appreciated!
Thanks
Delegation is what I needed:
FolderId InboxId = new FolderId(WellKnownFolderName.Inbox, "[email protected]");
FindItemsResults<Item> findResults = service.FindItems(InboxId, new ItemView(500));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With