Tuesday, September 25

Create an Exchange Calendar event using ASP

In one ASP program, registered user can write an event into internal Exchange Calendar.

'Set Appointment
Dim objAppt
Dim Conn
Set objAppt=CreateObject("CDO.Appointment")
Set Conn=CreateObject("ADODB.Connection")
Conn.Provider="ExOLEDB.Datasource"
LabelColor = 4 ' can be 0-10. 0 is white.
With objAppt
.StartTime = month &"/" & day & "/" & year & " "& hour & ":" &
minute & ":00 " & AMPM
.EndTime = appointmentEnd
.Subject = subject
.Location = address
.TextBody = description
.Fields("http://schemas.microsoft.com/mapi/id/
{00062002-0000-0000-C000-000000000046}/0x8214").Value =
clng(LabelColor)

.fields.update

CalenderSelector = "http://localhost/public/daily schedule/"
if (subject = "AAA") then
CalenderSelector = "http://localhost/public/special schedule/"
end if

Conn.Open CalenderSelector
.DataSource.SaveToContainer CalenderSelector, Conn
End With

'Cleanup
Set objAppt=Nothing
Set Conn=Nothing



There are two tricks in the code:
1, Define the color of label. You can modified the line "LabelColor = 4" to whatever you like. Value of the LabelColor can be any number between 0 and 10, and the result appointment will have different color respectfully. The method is undocumented. Make sure you use "Clng" to cast the value into long integer.

2, You can write to different calendar by using the CalendarSelector.

Labels: ,

2 Comments:

At November 26, 2007 6:01 AM, Anonymous bluesea said...

白写了,现在都.net了。里面的日历比你自己写的好用很多。你彻底落伍了。。。

 
At November 27, 2007 3:56 AM, Blogger Ben said...

前人留下来的程序,能够添加一个日历事件。我就在上面加上Label。我这里还有许多很古怪的垃圾程序...

 

Links to this post:

Create a Link

<< Home