Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
3
Erster Beitrag:
vor 1 Monat
Letzter Beitrag:
vor 1 Monat
Beteiligte Autoren:
iso, Arie

EWS - WD[22] Integration

Startbeitrag von iso am 07.11.2017 12:53

Hello,

I'm trying to integrate 'Microsoft Exchange Web Services Managed API 2.2' into Windev but am struggling to get started can anyone give me any pointers?

Many Thanks

ISO

Antworten:

ISO,

I have this working up to some point.
First you have to import the file Microsoft.Exchange.WebServices.dll and this file also needs to be on the client machine (i.e. in you app directory) at runtime,
You also need a useraccount with EWS option enabled. I don't know how this option is shown in Exchange, in my case the IT-guys took care of this.

1. I managed to connect to a running Exchange webservice Including the use of a callback function, which handles certificate checks. This callback is required btw.
2. I'm able to add an appointment and get it's Exchange ID.
3. I'm also able to modify this appointment with the use of that ID

However: I also had the need to register for notifications. This mechanism provides you with every change you subscribe for. So if the user move the appointment, in Outlook, to antoher date, you will get notified by that.
This notification subscription uses some advanced .NET objects and I did not manage to get that working with Windev. Took me several hours and in the end I stopped.

I ended up writing a liitle C#-tool using Visual Studio to do the job. It uses OLEDB to make the necessary changes in my HFSQL database. This works very well. There are TONS of C# (or VB if you are more comfortable with that) on the internet on how to use the EWS API.

But here is some code to connet to EWS from Windev.


m_sEwsAddress is string = "https://yourserver/ews/exchange.asmx";
m_sEwsUser is string = "someuser"
m_sEwsPasssword is string = "somepassword"
m_nEwsVersion = 3 // 3 = Exchange2010

v is Microsoft.Exchange.WebServices.Data.ExchangeVersion(m_nEwsVersion)
clOurService is Microsoft.Exchange.WebServices.Data.ExchangeService(v)
clOurService.Credentials = new WebCredentials(m_sEwsUser, m_sEwsPasssword);
// not working? clOurService.AutodiscoverUrl("arie@company.com", null);
clUri is System.Uri(m_sEwsAddress)
clOurService.Url = clUri

ServicePointManager.ServerCertificateValidationCallback = DotNetDelegate("EWS_Callback","RemoteCertificateValidationCallback")

clOurBody is Microsoft.Exchange.WebServices.Data.MessageBody
clOurBody.Text = "Let's learn to really work as a team and then have lunch!";
clOurAppointment is Microsoft.Exchange.WebServices.Data.Appointment(clOurService)
clOurAppointment.Subject = "Team building exercise";
clOurAppointment.Body = clOurBody

dTmp is Date
clDateTime1 is System.DateTime(Val(Left(dTmp,4)),Val(Middle(dTmp,5,2)),Val(Right(dTmp,2)),10,0,0)
clDateTime2 is System.DateTime(Val(Left(dTmp,4)),Val(Middle(dTmp,5,2)),Val(Right(dTmp,2)),12,0,0)

clOurAppointment.Start = clDateTime1
clOurAppointment.End = clDateTime2
clOurAppointment.Location = "Conference Room 12";
clOurAppointment.RequiredAttendees.Add("jean@company.com");
clOurAppointment.RequiredAttendees.Add("peter@company.com");
clOurAppointment.ReminderMinutesBeforeStart = 60;

WHEN EXCEPTION IN
clOurAppointment.Save(SendInvitationsMode::SendToAllAndSaveCopy)
DO
Error(ExceptionInfo(errFullDetails))
END

// Verify that the appointment was created by using the appointment's item ID.
//clOurAppointment = Item.Bind(clOurService, clOurAppointment.Id, new PropertySet(ItemSchema.Subject));
sID is string = clOurAppointment.Id.Tostring()

pclNItemID is object dynamic ItemId
pclNItemID = new ItemId(sID)
//idItm is Item = Item.bind(clOurService, clNItemID, PropertySet.FirstClassProperties);
clOurAppointment2 is object dynamic Microsoft.Exchange.WebServices.Data.Appointment
clOurAppointment2 = new "Microsoft.Exchange.WebServices.Data".Appointment(clOurService)
//clPropset is PropertySet
//clPropset.Add(PropertySet.FirstClassProperties)
//clOurAppointment2 = Appointment.Bind(clOurService, clNItemID, clPropset)
clOurAppointment2 = Appointment.Bind(clOurService, pclNItemID)
clOurAppointment2.Subject = "Team building exercise for all"

WHEN EXCEPTION IN
clOurAppointment2.Update(ConflictResolutionMode::AlwaysOverwrite,SendInvitationsMode::SendToAllAndSaveCopy)
DO
Error(ExceptionInfo(errFullDetails))
END



and this is the callback function. In there you get ino about the certificate used and can decide to continue, or not.


PROCEDURE EWS_Callback(sender, Certificate, chain, SslPolicyErrors)

RESULT True



von Arie - am 08.11.2017 09:13
Hello Arie,

Many thanks for that its helped me a lot, but it does seem like once you crack one bit then it leads to another problem, i'm going to keep plodding on until ive had enough then i might also consider writing it in c

All i'm trying to do is sync users meetings/appointments.

again thanks and if i have any success i ll let you know

ISO

von iso - am 08.11.2017 12:15
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.