Adding Calendar entries via Lotusscript

Hello everyone,

I’m trying to insert Calendar entries into our user’s calendars via LotusScript from another database. I recently upgraded to R8, and I’m having problems getting the Calendar entries to show up now, although it looks like they are being saved properly and in the correct mailfile.

Here’s an exerpt of the current code:

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument 'Dates for appointments come from current DB

'excluded code: Getting the dbMailFile from NAB

Set docnab = dbMailFile.CreateDocument

docNab.Form = “Appointment”

docNab.Subject = “SubjectField”

docNab.AppointmentType = “2”

docNab.StartDateTime = uidoc.FieldGettext(“Date”) + " 08:00 CET"

docnab.endDateTime = uidoc.FieldGettext(“theDate”) + " 17:00 CET"

docnab.StartDate = uidoc.FieldGettext(“theDate”)

docnab.EndDate = uidoc.FieldGettext(“theDate”)

docnab.Principal = uidoc.Fieldgettext(“Verlof_Aanvrager”)

docnab.CalendarDateTime = uidoc.FieldGettext(“theDate”)

docnab.excludeFromView = “D”

doc.SaveOptions = “”

Call docnab.save(True,True)

Does anybody have any ideas on what I’m forgetting or doing wrong?

Thank you for the feedback.

Subject: A few things to look at

Dirk -

A few things:

  1. Did this code work on a different version of Notes, and stop working on R8? Or is it brand new code?

  2. Are you sure you want AppointmentType=“2” there? Because that corresponds to “All Day Event”, but you’re specifying start and end times.

  3. I don’t think that “xx/xx/yyyy HH:MM CET” is a valid date/time string. Not sure, but you might have to remove the “CET”.

  4. I don’t know what your field data looks like, but I suspect you’re incorrectly mixing text strings that contain dates only, and ones that contain dates and times together.

  5. In the calendar view of the R8 Standard client, you should be able to find the “bad” entries that were created in the Views-Lists-Calendar Entries view (in the list of views just below the calendar widget on the left. They’ll probably be at the very top of the view with an “Incorrect data type” error in place of the date.

  6. Here’s some code that works a little better, based on what your posted code was. You can paste it in as an agent in your mailfile for testing.

Sub Initialize

Dim session As New NotesSession

Dim dbMailFile As NotesDatabase

Dim docnab As NotesDocument

Dim dateField As String, dateTimeField As String



dateField = Cstr(Today)

dateTimeField = Cstr(Now)



Set dbMailFile = session.CurrentDatabase

Set docnab = dbMailFile.CreateDocument

docNab.Form = "Appointment"

docNab.Subject = "SubjectField"

docNab.AppointmentType = "2"

docNab.StartDateTime = Cdat(dateField + " 08:00")

docnab.endDateTime = Cdat(dateField + " 17:00")

docnab.StartDate = Cdat(dateField)

docnab.EndDate = Cdat(dateField)

docnab.Principal = session.UserName

docnab.CalendarDateTime = Cdat(dateTimeField)

docnab.excludeFromView = "D"

Call docnab.save(True,True)



Print "Created new doc: " & docnab.NoteID

End Sub

Subject: Thanks

Thank you very much!