private void btnSyncCalendarCategories_Click(object sender, RibbonControlEventArgs e) { // the format of the EWS URL should be https://owa.youdomain.com/EWS/Exchange.asmx" string mbx = Globals.ThisAddIn.OWAUsername; ICalendarService calendarService = new EwsCalendarService(Globals.ThisAddIn.OWAUrl, mbx, Globals.ThisAddIn.OWAPassword); var categories = calendarService.GetCategories(); Globals.ThisAddIn.Categories = categories.Category; Sheets.CalendarCategoryWorksheet.Instance.CreateOrUpdateCalendarCategoriesOnSheet(categories); }
async Task SaveOWACredntialsAsync() { var validationResult = await ValidateAsync().ConfigureAwait(false); if (validationResult.IsValid) { Globals.ThisAddIn.OWAUrl = OWAUrl; Globals.ThisAddIn.OWAUsername = userName; Globals.ThisAddIn.OWAPassword = password; _ = await Task.Run(() => { return(""); }).ConfigureAwait(false); ICalendarService calendarService = new EwsCalendarService(Globals.ThisAddIn.OWAUrl, Globals.ThisAddIn.OWAUsername, Globals.ThisAddIn.OWAPassword); var categories = calendarService.GetCategories(); Globals.ThisAddIn.Categories = categories.Category; Sheets.CalendarCategoryWorksheet.Instance.CreateOrUpdateCalendarCategoriesOnSheet(categories); CloseAction(); // Invoke the Action previously defined by the View // do stuff async } }
private void btnCalendar_Click(object sender, RibbonControlEventArgs e) { // the format of the EWS URL should be https://owa.youdomain.com/EWS/Exchange.asmx" string mbx = Globals.ThisAddIn.OWAUsername; ICalendarService calendarService = new EwsCalendarService(Globals.ThisAddIn.OWAUrl, mbx, Globals.ThisAddIn.OWAPassword); try { if (Globals.ThisAddIn.Categories is null) { var categories = calendarService.GetCategories(); Globals.ThisAddIn.Categories = categories.Category; Sheets.CalendarCategoryWorksheet.Instance.CreateOrUpdateCalendarCategoriesOnSheet(categories); } var appointments = calendarService.GetAppointments(Globals.ThisAddIn.CalSyncStartDate, Globals.ThisAddIn.CalSyncEndDate); Sheets.Sheet1.Instance.WriteCalendarRows(appointments); } catch (Exception ex) { MessageBox.Show(ex.Message); } }