Lotus Notes Appointments from VB or VBA
This piece of code shows you how to book an appointment, even
someone else's calendar from VBA. I have shown how to create the mail file name
as first initial last name concatenated to eight character. You will need
to use whatever code to create the name based on your db naming convention.
'Public Sub SendNotesAppointment(Username
as string, Subject as string, attachment as string,
'recipient as string, Body as string, AppDate as Date, Duration as
integer)
'This public sub will write an appointment to a persons diary
'Please specify person as first name lastname
'also change the servername to reflect the notes server name
Public Sub SendNotesAppointment(UserName As
String, Subject As String, Body As String, AppDate As Date, Duration As
Integer)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim MailDbName As String 'The persons notes mail
database name
Dim CalenDoc As Object 'The calendar entry itself
Dim WorkSpace As Object
Set WorkSpace = CreateObject("Notes.NOTESUIWORKSPACE")
'Get the engineer username and then calculate the mail file name
MailDbName = Left$(UserName, 1) & Right$(UserName,
(Len(UserName) - InStr(1, UserName, " ")))
MailDbName = "mail\" & Left$(MailDbName,
8) & ".nsf"
'Create a new calender appointment based on template and set the
attributes.
Set CalenDoc = WorkSpace.COMPOSEDOCUMENT("SERVERNAME",
MailDbName, "Appointment")
CalenDoc.FIELDSETTEXT "AppointmentType",
"2"
CalenDoc.FIELDSETTEXT "StartDate", CStr(Format(Date,
"dd/mm/yy"))
CalenDoc.FIELDSETTEXT "Duration", CStr(Duration)
CalenDoc.FIELDSETTEXT "Subject", Subject
CalenDoc.FIELDSETTEXT "Body", Body
CalenDoc.Save False, False, False
CalenDoc.Close
Set Maildb = Nothing
Set CalenDoc = Nothing
Set WorkSpace = Nothing
End Sub |
Joe @ vortex web design has extended this code to provide much more functionality. He has posted the new code on his website
|