I'm using a workaround for the limitations of CDO not
being able to create or copy appointment items to anywhere
other than the default calendar. The workaround basically
involves using GetFolder to retrieve the default calendar
and then copy the message to the required location. Here's
the code:
The problem with this is if I use the GetLast() method, a
few lines up, it will return the last message in the
default calendar which isn't necessarily the last message
created. I've tried using the GetMessage method, i.e.
but this doesn't work, presumably because it's returning
the message as an appointment item and not a message and
the CopyTo method doesn't support appointment items. Are
there any better ways of creating appointments in public
folders, etc or any workarounds for the above problem?
Thanks in advance,
Mark
being able to create or copy appointment items to anywhere
other than the default calendar. The workaround basically
involves using GetFolder to retrieve the default calendar
and then copy the message to the required location. Here's
the code:
Code:
strMailbox = "whoever"
strProfileInfo = strServer & vbLf & strMailbox
Set objSession = Server.CreateObject("MAPI.Session")
objSession.Logon , , False, True, 0, True, strProfileInfo
'get the public folder
Set objPublicFolder = getPublicFolder()
'get the calendar for the specified room
Set objBookingsFolder = findSubFolders
(objPublicFolder, "Bookings")
Set objRoomsFolder = findSubFolders
(objBookingsFolder, "Rooms")
Set objCalendar = objSession.GetDefaultFolder
(CdoDefaultFolderCalendar)
strCalendarID = objCalendar.ID
Set objRoom = objSession.GetFolder(strRoom, strStoreID)
'add the appointment to the default calendar
Set objBooking = objCalendar.Messages.Add
With objBooking
.Type = "IPM.Appointment"
.Importance = 1
.TimeReceived = Now
.Subject = Request.Form("subject")
.Location = objRoom.Name
.Text = Request.Form("text")
.BusyStatus = 2 'set this to busy
.StartTime = strStartTime
.EndTime = strEndTime
.Update
End With
Set objCalendar = objSession.GetFolder(strCalendarID,
NULL) 'get the folder to copy the booking from
Set objBooking = objCalendar.Messages.GetLast() 'get the
last message created
Set objCopyBooking = objBooking.CopyTo(objRoom.ID) 'get
the booking to copy
objCopyBooking.Update 'save it
The problem with this is if I use the GetLast() method, a
few lines up, it will return the last message in the
default calendar which isn't necessarily the last message
created. I've tried using the GetMessage method, i.e.
Code:
Set objBooking = objSession.GetMessage(objBooking.ID,
objBooking.StoreID)
but this doesn't work, presumably because it's returning
the message as an appointment item and not a message and
the CopyTo method doesn't support appointment items. Are
there any better ways of creating appointments in public
folders, etc or any workarounds for the above problem?
Thanks in advance,
Mark