Link to home
Start Free TrialLog in
Avatar of jfvon
jfvon

asked on

Lotus Notes Calendar Programming from Visual Basic

We have a VB application that allows a user to schedule a call back to a client.  The user provides call back adte and time, subject line, and add'l notes (to be contained in the body of a 'reminder' calendar entry).The VB code creates an instance of a Lotus Notes workspace and adds a 'reminder' for the user to call back the client. The problem we are experiencing is that we cannot get the add'l notes to add to the 'Body' property of the 'reminder' entry.  When reviewing the property via Notes, the 'Body' feld is set to SEAL. So, I suspect this is causing the issue.  Can anyone assist with updating/setting this flag programmatically so the "body' of the 'reminder' will contain the add'l notes?  Time is of the essence!  

I've included code below.  Thanks for your help.

Private Function ScheduleCallBack() As Boolean

    'error handler
    On Error GoTo ErrHandler
   
    'local declares
    Dim oCalenDoc   As Object   'calendar entry
    Dim oWorkSpace  As Object   'notes workspace
    Dim iLoop       As Integer  'loop counter
    Dim sBody       As String   'body of reminder
    Dim sSTime      As String   'start time
    Dim sSubject    As String   'subject line
   
    '-----------------------------------------------
    ' date and time validation
    '-----------------------------------------------
    'exit if no time selected
    If cboTime.ListIndex = -1 Then
        MsgBox "Please select a time for call back.", vbExclamation, "Error"
        ScheduleCallBack = False
        Exit Function
    End If
   
    'exit if call back date/time have passed
    If CDate(txtDate & " " & cboTime) < (gvDate & " " & Time) Then
        If MsgBox("Scheduled Call Back is in the past. Schedule anyway?", vbQuestion + vbYesNo, "Confirm Request") = vbNo Then
            ScheduleCallBack = False
            Exit Function
        End If
    End If
   
    '-----------------------------------------------
    ' initial tasks
    '-----------------------------------------------
    Screen.MousePointer = vbArrowHourglass
    iLoop = 0
    sBody = Trim(txtNotes)
    sSubject = "Call Back: " & Trim(gsName) & " - SSN: " & gsSSN
    sSTime = CStr(FormatDateTime(CDate(cboTime), vbShortTime))
    Set oWorkSpace = CreateObject("Notes.NOTESUIWORKSPACE")
    Set oCalenDoc = oWorkSpace.COMPOSEDOCUMENT(gsMailServer, gsMailFile, "Appointment")
   
    'set calendar entry to 'reminder' appointment type
    oCalenDoc.FIELDSETTEXT "AppointmentType", "4"
    oCalenDoc.Refresh
   
    '-----------------------------------------------
    ' assign values to date/time entry fields
    ' loop count is done to prevent endless loop
    '-----------------------------------------------
    Do Until (CDate(Right(oCalenDoc.FIELDGETTEXT("StartDate"), 10)) = CDate(txtDate)) Or iLoop = 1000
        oCalenDoc.FIELDSETTEXT "StartDate", CStr(FormatDateTime(txtDate, vbShortDate))
        oCalenDoc.Refresh
        iLoop = iLoop + 1
    Loop
    iLoop = 0
   
    Do Until (CDate(oCalenDoc.FIELDGETTEXT("StartTime")) = CDate(sSTime)) Or iLoop = 1000
        oCalenDoc.FIELDSETTEXT "StartTime", sSTime
        oCalenDoc.Refresh
        iLoop = iLoop + 1
    Loop
    iLoop = 0
   
    Do Until (CDate(Right(oCalenDoc.FIELDGETTEXT("EndDate"), 10)) = CDate(txtDate)) Or iLoop = 1000
        oCalenDoc.FIELDSETTEXT "EndDate", CStr(FormatDateTime(txtDate, vbShortDate))
        oCalenDoc.Refresh
        iLoop = iLoop + 1
    Loop
    iLoop = 0
   
    Do Until (CDate(oCalenDoc.FIELDGETTEXT("EndTime")) = CDate(sSTime)) Or iLoop = 1000
        oCalenDoc.FIELDSETTEXT "EndTime", sSTime
        oCalenDoc.Refresh
        iLoop = iLoop + 1
    Loop
   
    '-----------------------------------------------
    ' assign remaining values and save entry
    '-----------------------------------------------
    oCalenDoc.FIELDSETTEXT "Subject", sSubject
    oCalenDoc.FIELDSETTEXT "Body", sBody
    oCalenDoc.Refresh
    oCalenDoc.Save
    oCalenDoc.Close
   
    '-----------------------------------------------
    ' delete references
    '-----------------------------------------------
    If oCalenDoc Is Nothing = False Then
        Set oCalenDoc = Nothing
    End If
    If oWorkSpace Is Nothing = False Then
        Set oWorkSpace = Nothing
    End If

    '----------------------------------------
    'update the return value
    '----------------------------------------
    ScheduleCallBack = True
    MsgBox "Call Back has been scheduled for " & txtDate & " " & cboTime & ".", vbInformation + vbOKOnly, "Information"

NormalExit:
    Screen.MousePointer = vbDefault
    Exit Function

ErrHandler:
    gsShowError Err.Number, Err.Description, "ScheduleCallBack"
    ScheduleCallBack = False
    Resume NormalExit
   
End Function
ASKER CERTIFIED SOLUTION
Avatar of SysExpert
SysExpert
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial