Technology is moving fast and sharepoint,office,live meeting and a lot more has been moved as cloud and branded as Office 365. It is really covering (365) all angles in mathematical terms of geometry. So let hit a try with it.
Microsoft Office 365 is a commercial software plus services offering a set of products from Microsoft Corporation, with the initial plan including a Professional subscription (for organizations of 25 and smaller) and an Enterprise subscription (for organizations with more individuals). Office 365 was announced in the autumn of 2010, and is currently in beta.
Office 365 includes the Microsoft Office suite of desktop applications and hosted versions of Microsoft’s Server products (including Exchange Server, SharePoint Server, and Lync Server), delivered and accessed over the Internet, in effect, the next version of Business Productivity Online Services (BPOS).
Autodiscover service provides the configuration information that you need to create a connection to an Exchange Online server. Using Autodiscover to identify the EWS endpoint is more reliable than hardcoding the URL.
SOAP Autodiscover service, which uses SOAP as the messaging framework for communications that are sent between the client and the server. To use the Autodiscover service, set the service binding by using the AutodiscoverUrl method. Do not hard code URLs because if mailboxes move, they might be serviced by a different Client Access server. If the client cannot connect to the service, retry setting the binding by using the AutodiscoverUrl method.
Following code method return EWS URL based on:
1. service account address
2. service account password
3. user address for whom EWS url is required
4. Version of exchange under target
private static string GetExternalEWSURL(string serviceAccountSMTPAddress, string serviceAccountPassword, string userSMTPAddress, ExchangeVersion exchangeVersion)
// Define the credentials to use.
var credentials = new WebCredentials(serviceAccountSMTPAddress, serviceAccountPassword);
// Create an instance of the AutodiscoverService.
Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService _autodiscoverService = new
// Enable tracing.
_autodiscoverService.TraceEnabled = true;
// Set the credentials.
_autodiscoverService.Credentials = credentials;
// Prevent the AutodiscoverService from looking in the local Active Directory
// for the Exchange Web Services Services SCP.
_autodiscoverService.EnableScpLookup = false;
// Specify a redirection URL validation callback that returns true for valid URLs.
_autodiscoverService.RedirectionUrlValidationCallback = RedirectionUrlValidationCallback;
// Get the Exchange Web Services URL for the user's mailbox.
GetUserSettingsResponse response =
// Extract the Exchange Web Services URL from the response.
string url = response.Settings[UserSettingName.ExternalEwsUrl].ToString();
static bool RedirectionUrlValidationCallback(string redirectionUrl)
// The default for the validation callback is to reject the URL.
bool result = false;
Uri redirectionUri = new Uri(redirectionUrl);
// Validate the contents of the redirection URL. In this simple validation
// callback, the redirection URL is considered valid if it is using HTTPS
// to encrypt the authentication credentials.
if (redirectionUri.Scheme == "https")
result = true;
Call this method for PBOS and Office 365 as below.
// For office 365 : exchange version is exchange 2010 SP1
string _userSMTPAddress = "firstname.lastname@example.org";
string _serviceAccountSMTPAddress = "email@example.com";
string _serviceAccountPassword = "we23R";
GetExternalEWSURL(_serviceAccountSMTPAddress, _serviceAccountPassword, _userSMTPAddress,ExchangeVersion.Exchange2010_SP1);
// For BPOS : exchange version is exchange 2007 SP1
_userSMTPAddress = "firstname.lastname@example.org";
_serviceAccountSMTPAddress = "email@example.com";
_serviceAccountPassword = "web33R";
GetExternalEWSURL(_serviceAccountSMTPAddress, _serviceAccountPassword, _userSMTPAddress, ExchangeVersion.Exchange2007_SP1);