Skip to content

Instantly share code, notes, and snippets.

@VibhuKuchhal
Last active April 19, 2016 05:05
Show Gist options
  • Save VibhuKuchhal/4c28574c1b2c2b0307f6 to your computer and use it in GitHub Desktop.
Save VibhuKuchhal/4c28574c1b2c2b0307f6 to your computer and use it in GitHub Desktop.
public ExchangeRepository()
{
serviceInstance = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
//Provide the account user credentials
serviceInstance.Credentials = new WebCredentials(ConfigurationManager.AppSettings["User"].ToString(),
ConfigurationManager.AppSettings["Password"].ToString(),
ConfigurationManager.AppSettings["Domain"].ToString());
try
{
// Use Autodiscover to set the URL endpoint.
serviceInstance.AutodiscoverUrl(ConfigurationManager.AppSettings["MailBox"].ToString());
}
catch (Exception ex)
{
serviceInstance = null;
ExceptionMessage = ex.Message;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment