My workplace has a heavy investment in Microsoft Exchange. We also have a very heavy investment in ColdFusion. So, we've tried to set the two up on a blind date for years. This past year, we finally started to see sparks. It turns out that Exchange can be accessed with WebDav for the purpose of creating Exchange Items. With a little work, ColdFusion can communicate using WebDav. With a little more work, ColdFusion can create Exchange Objects.
The CFC below will allow developers to create contacts and appointments on a remote Exchange server. This CFC is not intended to be an exhaustive run down of what you can do. There are well over a hundred attributes that you can fool with in an Exchance object. If you need to handle properties other than we take on in this CFC, you can find a longer list of them at these following locations.
The "we" of which I have been referring are two fellow Wharton Computing Employees and myself.
Using the code below we have done the following:
[1]I imagine that you don't need HTTPS to do it, but my exchange administrators insisted, so there you go.
[2]Or the username and password of the user of the mailbox you are trying to modify. But as coded this cfc doesn't allow that which is why I'm making the soruce avaialable.
| exchange_user: | The Active Directory account with "Exchange Mailbox Admins" privs. |
|---|---|
| exchange_password: | The password for that account |
| domaincontroller: | The dns hostname of an Active Directory Domain Controller against which to make ldap calls. |
| ldaproot: | The ldap serach root of the Active directory domain. |
| cflogname: | An arbitrary name for the CFlog to use to track this stuff. |
Here's a sample contact creation.
1: <cfinvoke component="Exchange" method="CreateUpdateExchangeContact" returnvariable="CreateUpdateExchangeContactRet">
2: <cfinvokeargument name="exchangeUsername" value="[username]"/>
3: <cfinvokeargument name="FirstName" value="Earl" />
4: <cfinvokeargument name="LastName" value="Ragefest" />
5: <cfinvokeargument name="OfficeNumber" value="(215) 555-1234" />
6: <cfinvokeargument name="PrimaryEmail" value="earl.ragefest@gmail.com" />
7: <cfinvokeargument name="guid" value="D5DB7AE5-AA76-B59B-B0C1AC6E528E6FE3" />
8: </cfinvoke>
The cool thing about keeping track of Guid's is that they allow us to update the contact, so that if it turns out that Earl is not his real name, we can update the contact we created.
1: <cfinvoke component="Exchange" method="CreateUpdateExchangeContact" returnvariable="CreateUpdateExchangeContactRet">
2: <cfinvokeargument name="exchangeUsername" value="[username]"/>
3: <cfinvokeargument name="FirstName" value="Steven" />
4: <cfinvokeargument name="LastName" value="Ragefest III" />
5: <cfinvokeargument name="OfficeNumber" value="(215) 555-1234" />
6: <cfinvokeargument name="PrimaryEmail" value="earl.ragefest@gmail.com" />
7: <cfinvokeargument name="guid" value="D5DB7AE5-AA76-B59B-B0C1AC6E528E6FE3" />
8: </cfinvoke>
Now for Appointments, here's an easy, if unlikely, example.
1: <cfinvoke component="Exchange" method="CreateUpdateExchangeAppointment" returnvariable="CreateUpdateExchangeAppointmentRet">
2: <cfinvokeargument name="exchangeUsername" value="[username]"/>
3: <cfinvokeargument name="Subject" value="Lunch w/ Ben Forta"/>
4: <cfinvokeargument name="Location" value="Las Vegas - Maxx 2006"/>
5: <cfinvokeargument name="StartTime" value="12:00PM 10/24/2006"/>
6: <cfinvokeargument name="EndTime" value="2:00PM 10/24/2006"/>
7: </cfinvoke>