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);

    please..

    ..below are my codings :

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

    service.Credentials = new WebCredentials(CredentialCache.DefaultCredentials);
    //service.AutodiscoverUrl(mail);
    //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.PropertySet.Add(FolderSchema.DisplayName);
    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;
    DayPilotCalendar1.DataBind();

    DayPilotCalendar1.Update();

    }
  • #768585
    Hi,
    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;
    connection.Bind();
    Console.WriteLine("You have logged in ");



    Thanks,
    Mani

  • #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