You must Sign In to post a response.
  • Category: ASP.NET

    Retrieve outlook calendar with EWS

    hello.. can someone help me.. i have coding which i want to retrieve outlook calendar using EWS but i need to use the webCredential from Active Directory Credential.. how to put at the

    service.Credentials = new WebCredentials(CredentialCache.DefaultCredentials);


    ..below are my codings :

    private ExchangeService Service
    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);

    service.Credentials = new WebCredentials(CredentialCache.DefaultCredentials);
    //service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, mail);

    service.Url = new Uri("https://""/EWS/exchange.asmx");
    return service;

    private CalendarFolder FindDefaultCalendarFolder()
    return CalendarFolder.Bind(Service, WellKnownFolderName.Calendar, new PropertySet());

    private CalendarFolder FindNamedCalendarFolder(string name)

    FolderView view = new FolderView(100);
    view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
    view.Traversal = FolderTraversal.Deep;

    SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(FolderSchema.FolderClass, "IPF.Appointment");

    FindFoldersResults findFolderResults = Service.FindFolders(WellKnownFolderName.Calendar, sfSearchFilter, view);

    return findFolderResults.Where(f => f.DisplayName == name).Cast<CalendarFolder>().FirstOrDefault();

    private void LoadAppointments()
    DateTime startDate = DayPilot.Utils.Week.FirstDayOfWeek();
    DateTime endDate = startDate.AddDays(7);

    CalendarFolder calendar = FindNamedCalendarFolder("Calendar"); // or FindDefaultCalendarFolder()

    CalendarView cView = new CalendarView(startDate, endDate, 50);
    cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Id);
    FindItemsResults<Microsoft.Exchange.WebServices.Data.Appointment> appointment = calendar.FindAppointments(cView);

    DayPilotCalendar1.ViewType = ViewTypeEnum.Day;
    DayPilotCalendar1.DataStartField = "Start";
    DayPilotCalendar1.DataEndField = "End";
    DayPilotCalendar1.DataIdField = "Id";
    DayPilotCalendar1.DataTextField = "Subject";

    DayPilotCalendar1.DataSource = appointment;


  • #768585
    Have you tried to login using LDAP connection?
    Because LDAP is one of the easiest and effective way to get the outlook mail and its details.

    LdapConnection connection = new LdapConnection("yourconnection");
    NetworkCredential credential = new NetworkCredential("username", "password");
    connection.Credential = credential;
    Console.WriteLine("You have logged in ");


  • #768588
    i need to use Active Directory as all the system in my company uses Active Directory to access system. i obviously can't retrieve the password of Active Directory. please help.. i'm so desperate..

  • Sign In to post your comments