0
votes

I get the following error message;

Id is malformed.

CD0000008B9511D182D800C04FB1625DBA75FAB1A56555459257CE195FAEBE39

The ID comes from a table where I saved the ID when I created the reminder in the calendar.

CF9 and Exchange 2013:

<cfobject type="Java" class="microsoft.exchange.webservices.data.Appointment" name="appointment">
<cfobject type="Java" class="microsoft.exchange.webservices.data.AppointmentSchema" name="appointmentschema">
<cfset appointment.init( service )>
<cfobject type="Java" class="microsoft.exchange.webservices.data.PropertySet" name="propertyset">
<cfset propertyset.init()>
<cfobject type="Java" class="microsoft.exchange.webservices.data.ItemId" name="thisitemid">
<cfset thisitemid.init("#arguments.ExchangeID#")>
<cfset appointment = appointment.Bind(service, thisitemid) />
<cfscript>
    appointment.setStart(#StartDate#);
    appointment.setEnd(#EndDate#);
    appointment.setSubject("#Arguments.EventName#");
    appointment.setBody(MessageBody.getMessageBodyFromText("#Arguments.EventDescription#"));
    appointment.Update(ConflictResolutionMode.AlwaysOverwrite);
</cfscript>

Edit: The following code is what I use today to create an appointment. However, I haven't figured out how to return the correct "ID" of the appointment so I can save it in case the appointment needs to be deleted or updated.

    <cfobject type="Java" class="microsoft.exchange.webservices.data.ExchangeService" name="service">
    <cfset service.init()>
    <cfobject type="Java" class="microsoft.exchange.webservices.data.ExchangeVersion" name="version">
    <cfset service.init(version.Exchange2010)>
    <cfobject type="Java" class="microsoft.exchange.webservices.data.WebCredentials" name="credentials">
    <cfset credentials.init("#Arguments.EmailAddress#","#Arguments.Pword#")>
    <cfset service.setCredentials(credentials) />
    <cfobject type="Java" class="java.net.URI" name="uri">
    <cfset uri.init("https://south.exch999.serverdata.net/EWS/Exchange.asmx?wsdl")>
    <cfset service.setUrl(uri) />
<cfoutput>
    <cfobject type="Java" class="microsoft.exchange.webservices.data.Appointment" name="appointment">
    <cfset appointment.init( service )>
    <cfobject type="Java" class="microsoft.exchange.webservices.data.MessageBody" name="MessageBody">
    <cfscript>
    appointment.setStart(#createDateTime(Year(Arguments.EventStartDateTime),       Month(Arguments.EventStartDateTime),Day(Arguments.EventStartDateTime), evaluate(Hour(Arguments.EventStartDateTime)), Minute(Arguments.EventStartDateTime), 0)#);
    appointment.setEnd(#createDateTime(Year(Arguments.EventEndDateTime), Month(Arguments.EventEndDateTime),Day(Arguments.EventEndDateTime), evaluate(Hour(Arguments.EventEndDateTime)), Minute(Arguments.EventEndDateTime), 0)#);
    appointment.setSubject("#Arguments.EventName#");                        appointment.setBody(MessageBody.getMessageBodyFromText("#Arguments.EventDescription#"));
    appointment.Save();
    TheEventID = appointment.Id.UniqueId;
    </cfscript>

What property should I retrieve to save an ID that can be used to retrieve the appointment later?

1
I don't understand how propertydefinition plays in the scheme I setup in the above edited code.user990016
I'm saving the id as TheEventID = appointment.Id.UniqueId; But when I try to bind the appointment to update it I get the message: The specified object was not found in the store.user990016
Does this happen directly after saving the ID or just with entries that are much older? Are you converting it to hex when it goes into the database and converting it back to Base64 when creating a new ItemId from it? Is the example you posted an actual UniqueId string? If so, it's far too short.user1017413
I had just created the event and checked my DB. It is a completely different string (much longer) and NOT hex. I tried to modify the event and got the error "not found".user990016
AAMkADQyMGJhNjE0LTQzZjktNDRiMy05M2M4LWE0NTQxYzA5NWFhMABGAAAAAAD9wuji3kHlSpmR1oSZiZu0BwAnkNsBQ//TS7en1/EP1+R1AAAAAAEOAAAnkNsBQ//TS7en1/EP1+R1AAAuXUjwAAA=user990016

1 Answers

0
votes

That looks too short to be an ItemId. I think you may have saved the Global Unique Id or ICalUID from the Appointment instead, or perhaps a different Id that may be converterable via the ConvertId call.

Whoops, sorry, if that's the actual ID you're seeing then it definitely isn't the Global Unique Id. That property is prepended by a specific GUID that does not match what you've shown.

If that's not the full string and the ID you're pulling from the table is longer, then you may only need to convert it to a Base64 String before instantiating the ItemId. Do you have any further info on what exactly "theUID" is or how it is retrieved from the Appointment once it's saved?

If not, then I'm not certain what you're looking at. It doesn't seem to correlate to any specific property in Exchange that I'm aware of. You can try using ConvertId to convert them to other Id types and see if anything comes out (you'll likely have to do Base64 conversions on that hex first). It might be the OWA ID, but I haven't worked with those directly.

If you're looking for an Id, then Appointment.ItemId.UniqueId would work (a new ItemId can be instantiated from the UniqueId string), but be aware that it is NOT an immutable property and can be changed by Exchange if the Appointment is moved to another folder or, supposedly, if a service pack is installed or enough time passes. It should only be used in the short term. You could use the Global Unique Id, but you'd have to explicitly load it as an extended property once the Appointment has been saved. However, the Global Unique Id would require a FindItems operation to retrieve items based on it, and it isn't indexed, so performance might not be so great if you have large folders and frequent searches. You might try a combination of the two: Appointment.Bind with an ItemId and a doublecheck on the Global Unique Id to be sure it's correct, or fall back on it and search if the Appointment could not be found. Alternatively, you could use your own ID instead of the Global Unique Id.

Also, if you're going to use the Global Unique Id, be aware of the Clean Global Unique Id and how they relate to recurrences if you plan on having them.