I am trying to read appointments in outlook using exchange web service. Has anybody done that and if yes, would you be so kind and share the code. thanks
Hi
I am using OE11.3 on windows Server 2008.
I have put together the following code but I can't figure out what sort of object I need in the find command (= calendar.findAppointments(cview). Using cappt is giving me incompatible data type. I tried various ones but can't get it to work.
Below is my code example:
USING System.*.
USING Microsoft.Exchange.WebServices.Data.*.
USING System.Net.Security.*.
USING System.Security.Cryptography.X509Certificates.*.
DEFINE VARIABLE service AS ExchangeService.
DEFINE VARIABLE ApptStart AS DATETIME.
DEFINE VARIABLE ApptEnd AS DATETIME.
apptStart = NOW.
apptEnd = NOW + 3600000.
service = NEW ExchangeService(ExchangeVersion:Exchange2013) .
service:credentials = NEW WebCredentials("myemailaddress", "").
service:AutodiscoverUrl("myurl").
def var cView as Microsoft.Exchange.WebServices.Data.CalendarView.
def var calendar as Microsoft.Exchange.WebServices.Data.CalendarFolder.
def var cappt as Microsoft.Exchange.WebServices.Data.Appointment.
calendar = CalendarFolder:Bind(service, WellKnownFolderName:Calendar, new PropertySet()).
cView = new CalendarView(apptStart, apptEnd, 5).
cappt = calendar:FindAppointments(cView).
message cappt:Subject.
Flag this post as spam/abuse.
Hi,
What version of Openedge are you working with ? When I've previously looked at this, I was going to use a .NET Framework API, to hide some of the complexity.
I've used an evaluation version from www.independentsoft.de/index.html which has worked great. For example, to read appointments from today onwards using their C# example looks like this;
using System; using System.Net; using Independentsoft.Exchange; namespace Sample { class Program { static void Main(string[] args) { 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]; Console.WriteLine("Subject = " + appointment.Subject); Console.WriteLine("StartTime = " + appointment.StartTime); Console.WriteLine("EndTime = " + appointment.EndTime); Console.WriteLine("Body Preview = " + appointment.BodyPlainText); Console.WriteLine("----------------------------------------------------------------"); } } Console.Read(); } 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(); } } } }
Not linked to the company (!), but seems competitively priced at 299 euros for a developer license.
HTH.
There are a number of very interesting blog posts on www.thesoftwaregorilla.com/.../exchange-ews
Hi
I am using OE11.3 on windows Server 2008.
I have put together the following code but I can't figure out what sort of object I need in the find command (= calendar.findAppointments(cview). Using cappt is giving me incompatible data type. I tried various ones but can't get it to work.
Below is my code example:
USING System.*.
USING Microsoft.Exchange.WebServices.Data.*.
USING System.Net.Security.*.
USING System.Security.Cryptography.X509Certificates.*.
DEFINE VARIABLE service AS ExchangeService.
DEFINE VARIABLE ApptStart AS DATETIME.
DEFINE VARIABLE ApptEnd AS DATETIME.
apptStart = NOW.
apptEnd = NOW + 3600000.
service = NEW ExchangeService(ExchangeVersion:Exchange2013) .
service:credentials = NEW WebCredentials("myemailaddress", "").
service:AutodiscoverUrl("myurl").
def var cView as Microsoft.Exchange.WebServices.Data.CalendarView.
def var calendar as Microsoft.Exchange.WebServices.Data.CalendarFolder.
def var cappt as Microsoft.Exchange.WebServices.Data.Appointment.
calendar = CalendarFolder:Bind(service, WellKnownFolderName:Calendar, new PropertySet()).
cView = new CalendarView(apptStart, apptEnd, 5).
cappt = calendar:FindAppointments(cView).
message cappt:Subject.
Hi
I am using OE11.3 on windows Server 2008.
I have put together the following code but I can't figure out what sort of object I need in the find command (= calendar.findAppointments(cview). Using cappt is giving me incompatible data type. I tried various ones but can't get it to work.
Below is my code example:
USING System.*.
USING Microsoft.Exchange.WebServices.Data.*.
USING System.Net.Security.*.
USING System.Security.Cryptography.X509Certificates.*.
DEFINE VARIABLE service AS ExchangeService.
DEFINE VARIABLE ApptStart AS DATETIME.
DEFINE VARIABLE ApptEnd AS DATETIME.
apptStart = NOW.
apptEnd = NOW + 3600000.
service = NEW ExchangeService(ExchangeVersion:Exchange2013) .
service:credentials = NEW WebCredentials("myemailaddress", "").
service:AutodiscoverUrl("myurl").
def var cView as Microsoft.Exchange.WebServices.Data.CalendarView.
def var calendar as Microsoft.Exchange.WebServices.Data.CalendarFolder.
def var cappt as Microsoft.Exchange.WebServices.Data.Appointment.
calendar = CalendarFolder:Bind(service, WellKnownFolderName:Calendar, new PropertySet()).
cView = new CalendarView(apptStart, apptEnd, 5).
cappt = calendar:FindAppointments(cView).
message cappt:Subject.
Flag this post as spam/abuse.
Hi Tom
You are a champion, that is exactly what I was looking for. Next time you are down under at the Progress Conference, I will buy you a beer or two.
cheers
Thomas
Hi Tom
Appointments work the same as emails, I just had to replace the word 'emailMessage' with 'Appointment' and it worked.
Cheers
Thomas