protected void Page_Load(object sender, EventArgs e) { NetworkCredential credential = new NetworkCredential("username", "password"); Service service = new Service("https://myserver/ews/Exchange.asmx", credential); try { IsGreaterThanOrEqualTo restriction1 = new IsGreaterThanOrEqualTo(AppointmentPropertyPath.StartTime, DateTime.Today); IsLessThanOrEqualTo restriction2 = new IsLessThanOrEqualTo(AppointmentPropertyPath.EndTime, DateTime.Today.AddDays(1)); And restriction3 = new And(restriction1, restriction2); FindItemResponse response = service.FindItem(StandardFolder.Calendar, AppointmentPropertyPath.AllPropertyPaths, restriction3); for (int i = 0; i < response.Items.Count; i++) { if (response.Items[i] is Appointment) { Appointment appointment = (Appointment)response.Items[i]; lblSubject.Text = "Subject = " + appointment.Subject; lblStartTime.Text = "StartTime = " + appointment.StartTime; lblEndTime.Text = "EndTime = " + appointment.EndTime; lblBodyPreview.Text = "Body Preview = " + appointment.BodyPlainText; } } } catch (ServiceRequestException ex) { lblError.Text= "Error: " + ex.Message; lblXmlError.Text = "Error: " + ex.XmlMessage; Console.Read(); } catch (WebException ex) { lblWebError.Text = "Error: " + ex.Message; } }
static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "password"); Service service = new Service("https://myserver3/ews/Exchange.asmx", credential); try { ItemShape itemShape = new ItemShape(ShapeType.Id); FindItemResponse inboxItems = service.FindItem(StandardFolder.Inbox, itemShape); for (int i = 0; i < inboxItems.Items.Count; i++) { Independentsoft.Msg.Message msgFile = service.GetMessageFile(inboxItems.Items[i].ItemId); msgFile.Save("c:\\test\\message" + i + ".msg", true); } } catch (ServiceRequestException ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("Error: " + ex.XmlMessage); Console.Read(); } catch (WebException ex) { Console.WriteLine("Error: " + ex.Message); Console.Read(); } }
protected override FindItemJsonResponse CreateErrorResponse(Exception exception, ResponseCodeType codeType) { base.TraceError("FindItemAnonymous:CreateErrorResponse. Exception:{0}", new object[] { exception }); FindItemResponse findItemResponse = new FindItemResponse(); ServiceError error = new ServiceError(base.GetExceptionMessage(exception), codeType, 0, ExchangeVersion.Latest); findItemResponse.AddResponse(new ResponseMessage(ServiceResultCode.Error, error)); return(new FindItemJsonResponse { Body = findItemResponse }); }
protected override FindItemJsonResponse InternalExecute(PublishedCalendar publishedFolder) { object[][] data; try { data = this.GetData(publishedFolder); } catch (ArgumentException exception) { return(this.CreateErrorResponse(exception, ResponseCodeType.ErrorInvalidRequest)); } ServiceResult <FindItemParentWrapper> result = this.CreateServiceResponse(new FindItemAnonymous.AnonymousQueryView(data, int.MaxValue), publishedFolder); FindItemResponse findItemResponse = new FindItemResponse(); findItemResponse.ProcessServiceResult(result); return(new FindItemJsonResponse { Body = findItemResponse }); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); FindItemResponse resp = new FindItemResponse { Result = new List <Item>() { new Item { Name = "Name", Quantity = 1, Row = 2, Col = 3 } } }; string response = resp.ToJsonString(true); Console.WriteLine(response); Console.ReadKey(); }