UseDefaultCredentials with Exchange Web Services

I am a fairly new programmer. One of the things I've been tasked with working on is getting our own tools for creating draft emails and putting them in the email draft of the user running this tool. We are currently using Exchange Server 2010 (but in the process of migrating to Exchange Online).

This link talks about UseDefaultCredentials, but I can't figure out how to implement it. I created an ExchangeService object called service and was able to interact with our Exchange server using this for credentials:

service.Credentials = new WebCredentials ("my login name", "my password");

I would like to remove this from the code and use its credentials to log into the system that this tool uses. Is it possible?

+3
source share
2 answers
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new WebCredentials(CredentialCache.DefaultNetworkCredentials);
+3
source

if you use defaultcredentials, you can exclude your code. Just set UseDefaultCredentials to True and do not set credentials manually. In this case, the credentials of the user who runs your tool will be executed. I use it on my own and it works for me.

Cheers, J

+2
source

All Articles