Wednesday, July 28, 2004

Add creator to shared calender entry event sink

  One of the big pains i find when your using a shared calendar in a public folder is that you can't easily tell which user has created each of the calendar entries. I came up with the following sink for a small project I'm working on that will append the name of the creator to the location field of an appointment or meeting request when its created (this will mean it will appear in brackets when you look at the normal calendar view next to each appointment). You can grab the creator of a item from the "http://schemas.microsoft.com/mapi/proptag/0x3FF8001E" mapi property. 


Sub ExStoreEvents_OnSave(pEventInfo, bstrURLItem, lFlags)
on error resume next
Const EVT_NEW_ITEM = 1
Const EVT_IS_DELIVERED = 8

If (lFlags And EVT_IS_DELIVERED) Or (lFlags And EVT_NEW_ITEM) Then 
set apptobj = CreateObject("CDO.Appointment")
apptobj.datasource.open bstrURLItem,,3
creator = " Created by " & apptobj.fields("http://schemas.microsoft.com/mapi/proptag/0x3FF8001E").Value
apptobj.fields("urn:schemas:calendar:location") = apptobj.fields("urn:schemas:calendar:location") & creator
apptobj.fields.update
apptobj.datasource.save
end if
set apptobj = nothing

End Sub