Is it possibly to access the folders and items of other Exchange accounts other than the one of the logged in user?
Can I do this via Exchange Web Services Managed API?
Microsoft Exchange Web Services (EWS) is a native API built by Microsoft that allows server/client applications to integrate with Exchange Servers and Office 365. Connecting Salesloft to Office 365 or Exchange Server through Microsoft's EWS API allows access to calendars and emails.
See Upcoming changes to Exchange Web Services (EWS) API for Office 365. Many applications have successfully moved to Graph, but for those applications that have not, it's noteworthy that EWS already fully supports Modern authentication.
By default, the files are installed in C:\Program Files\Microsoft\Exchange\Web Services\2.0\ , but you can store the files anywhere on your computer. In the Solution Explorer pane in Visual Studio, select References, and then choose Add Reference.
Yes it is possible, but you should know the password of the other user or grab in some ways this credentials (NetworkCredential
object). The typical first lines of you code could be
ExchangeService myService = new ExchangeService (ExchangeVersion.Exchange2007_SP1);
myService.Credentials = new NetworkCredential ("[email protected]", "P@ssword00");
so you can access Exchange Server Web Services with the account which is other as the current user. See ExchangeService object description for more information.
If you are an admin you can make user impersonation by SMTP address.
Knowing the password is wrong and using impersonation (these days) is wrong.
Here's how you do it.
ExchangeService _service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
//CREDENTIALS OF AN ACCOUNT WHICH HAS READ ACCESS TO THE CALENDAR YOU NEED
_service.Credentials = new WebCredentials(username, password);
_service.Url = new Uri(serviceURL);
SearchFilter.SearchFilterCollection searchFilter = new SearchFilter.SearchFilterCollection();
searchFilter.Add(new SearchFilter.IsGreaterThanOrEqualTo(AppointmentSchema.Start, DateTime.Now.AddDays(-1)));
searchFilter.Add(new SearchFilter.IsLessThanOrEqualTo(AppointmentSchema.Start, DateTime.Now.AddDays(2)));
ItemView view = new ItemView(50);
view.PropertySet = new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.AppointmentType, AppointmentSchema.End);
//THIS NEXT LINE!!!
var calendarSearch = new FolderId(WellKnownFolderName.Calendar, new Mailbox("[email protected]"));
var appointments = _service.FindItems(calendarSearch, searchFilter, view);
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