Hi Everyone,
I am developing an application in VB that will add a new appointment document to a user’s lotus notes mail file. The VB application allows the user to add text to the body of the appointment using a rich text box on the VB form. I have the code written to add the appointment but when I append the text from the RichText box, it list the RichText coding and not the text with the correct formatting.
Does anyone know how to append richtext from a VB RTF box to lotus notes?
Here is a copy of my code:
Public Function AddCalEntry(UserName As String, UserPass As String, ByRef Subject As String, Body As RichTextBox, _
ApptDate As String, StartTime As Date, MinsDuration As Integer) As String
Dim MailDbName As String, strSTime As String, strETime As String
Dim MySession As New NotesSession
Dim NotesDB As NotesDatabase
Dim MyVW As NotesView
Dim CalenDoc As NotesDocument
Dim MyItem As NotesItem
Dim MyDocColl As NotesDocumentCollection
Dim RichTextItem As NotesRichTextItem
If Not UserPass = "~" Then
Call MySession.Initialize(UserPass)
Else
Call MySession.Initialize
End If
MailDbName = UserName + ".nsf"
Set NotesDB = MySession.GetDatabase(ServerName, MailDbName, False)
If Not NotesDB.IsOpen Then Exit Function
'On Error GoTo SendNotesErr
strSTime = CStr(FormatDateTime(StartTime, vbShortTime))
strETime = CStr(FormatDateTime(DateAdd("n", MinsDuration, StartTime), vbShortTime))
Set CalenDoc = NotesDB.CreateDocument
CalenDoc.ReplaceItemValue "Form", "Appointment"
CalenDoc.ReplaceItemValue "AppointmentType", "0"
CalenDoc.ReplaceItemValue "STARTDATETIME", CDate(ApptDate & " " & strSTime)
CalenDoc.ReplaceItemValue "CALENDARDATETIME", CDate(ApptDate & " " & strSTime)
CalenDoc.ReplaceItemValue "EndDateTime", CDate(ApptDate & " " & strETime)
CalenDoc.ReplaceItemValue "Subject", Subject
Set RichTextItem = CalenDoc.CreateRichTextItem("Body")
Call RichTextItem.AppendText(Body.TextRTF)
CalenDoc.ReplaceItemValue "MeetingType", 1
CalenDoc.ReplaceItemValue "$Alarm", 1
CalenDoc.ReplaceItemValue "$AlarmOffset", -20
CalenDoc.ReplaceItemValue "$PublicAccess", "1"
CalenDoc.ReplaceItemValue "_ViewIcon", 160
CalenDoc.ReplaceItemValue "$CSVersion", 2
CalenDoc.ReplaceItemValue "$BusyName", MySession.UserName
CalenDoc.ReplaceItemValue "$BusyPriority", "1" 'Show Busy = 1; Show Not Busy = 2
CalenDoc.ReplaceItemValue "BookFreeTime", "1" 'Not Checked = ""; Checked = "1"
CalenDoc.ReplaceItemValue "CHAIR", MySession.UserName
CalenDoc.ReplaceItemValue "ORGTABLE", "C0"
CalenDoc.ReplaceItemValue "ExcludeFromView", "D"
CalenDoc.ReplaceItemValue "Principal", MySession.UserName
CalenDoc.ComputeWithForm True, False
CalenDoc.Save True, False
SendNewNotesAppointment = CalenDoc.GetItemValue("ApptUNID")(0)
'myFrm.MousePointer = vbDefault
Exit Function
SendNotesErr:
SendNewNotesAppointment = False
End Function