public bool SetupCalendarEvent(string msg, string srtdate, string enddate, string[] rqdAttendeelist, string[] optionalAttendeelist, string UserID, string UserPassword,string workinghours) { EWSClass objEWS = new EWSClass(); ExchangeService objService = objEWS.CreateService(UserID, UserPassword,workinghours); IFormatProvider culture = new System.Globalization.CultureInfo("en-US", true); //DateTime startdate = DateTime.ParseExact(srtdate, "g", culture, DateTimeStyles.None); //DateTime endDate = DateTime.ParseExact(enddate, "g", culture, DateTimeStyles.None); DateTime startdate = DateTime.Parse(srtdate); DateTime endDate = DateTime.Parse(enddate); Appointment objAppoint = objEWS.GetAppointment(objService, msg, startdate, endDate); return objEWS.CreateCalendarEvent(objService, objAppoint,rqdAttendeelist,optionalAttendeelist); }
protected void btnSubmit_Click(object sender, EventArgs e) { GroupsClass obj = new GroupsClass(); // sharepointUrl = new Uri(Request.QueryString[Config.ListURL]); timeOffRequestID = Request.QueryString["RequestID"]; string[] reqdAtten = { RequestedByEmail }; string[] optAtten={}; if (UpdateStatus(((Button)sender).CommandArgument, "Approved")) { string msg = "Time Off Request of " + this.lblTimeoffType.Text + ": on " + this.txtStartDate.Text + " to " + this.txtEndDate.Text + " has been Approved"; EWSClass objEWS = new EWSClass(); if (this.lblFullday.Text == "Full Day(s)") { this.txtStartDate.Text += " 12:00 AM"; this.txtEndDate.Text += " 12:00 PM"; } string UserID = Config.SenderEmail;//default from web.config string UserPassword = Config.SenderPassword; string WorkingHours = Config.WorkingHours; ConfigListValues objConfigAppList = new ConfigListValues(); objConfigAppList.GetConfigValues(null); if (objConfigAppList.items != null) { if (objConfigAppList.items.ContainsKey("SenderEmail")) UserID = objConfigAppList.items["SenderEmail"].ToString(); if (objConfigAppList.items.ContainsKey("SenderPassword")) UserPassword = objConfigAppList.items["SenderPassword"].ToString(); if (objConfigAppList.items.ContainsKey("WorkingHours")) WorkingHours = objConfigAppList.items["WorkingHours"].ToString(); } objEWS.SetupCalendarEvent(msg, this.txtStartDate.Text, this.txtEndDate.Text, reqdAtten, optAtten, UserID, UserPassword, WorkingHours); try { string siteToken; if (Session["contextToken"] != null) { DeptCalListClass objDept = new DeptCalListClass(); siteToken = Session["contextToken"] as string; objDept.AddDeptCal(null, this.lblRequestedBy.Text + "-" + this.lblTimeoffType.Text, this.txtStartDate.Text, this.txtEndDate.Text); } } catch { } Response.Redirect("ui.aspx?SPHostUrl=" + Request.QueryString["SPHostUrl"].ToString() + "&approval=1&" + Config.ListURL + "=" + Request.QueryString["SPAppWebUrl"].ToString()); } Response.Redirect("ui.aspx?SPHostUrl=" + Request.QueryString["SPHostUrl"].ToString() + "&approval=0&" + Config.ListURL + "=" + Request.QueryString["SPAppWebUrl"].ToString()); }