search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Adding code to existing helper class for exchange

Related article: Loading Calendar Appointments from Exchange Server (Office 365) using EWS (ASP.NET)
Asked by Anonymous
6 years ago.

Hi there, I was wondering if there is some way to take this code from your example and build it into my Helper Class for exchange? The code:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new WebCredentials("UserID", "Password"); // not real :)
service.AutodiscoverUrl("support@organization.com");
service.Url = new Uri("https://************************************/exchange.asmx");
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "support@organization.com");

// this week
DateTime startDate = DayPilot.Utils.Week.FirstDayOfWeek();
DateTime endDate = startDate.AddDays(7);

try
{
// load the default calendar
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());

// load events
CalendarView cView = new CalendarView(startDate, endDate, 50);
cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Id);
FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);

// assign appointments
DayPilotCalendar1.DataSource = appointments;

// map item properties
DayPilotCalendar1.DataStartField = "Start";
DayPilotCalendar1.DataEndField = "End";
DayPilotCalendar1.DataIdField = "Id";
DayPilotCalendar1.DataTextField = "Subject";

// load and display appointments in DayPilot Calendar
DayPilotCalendar1.DataBind();
}
catch (Exception ex)
{
HttpContext.Current.Response.Write(ex.ToString());
}

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.