Hi all,
kinda banging my head against the wall here, and could do with some advice.
I am trying to write a piece of VB (it will be ASP eventually) which will take a set of data (meeting title, start time, attendee email addresses, etc) from our app, and interface with Lotus Notes to create a Lotus Notes Meeting/Invitation and then send out the Invitation to the Attendees via Lotus Notes e-mail. Ideally, we would like to allow the user to be able to manually edit the Invitation before it is sent to the Attendees, but I think that’s a bit far away at the moment.
So, I am using the Notes COM Toolkit to do this, and have now ran into a wall. Although I am able to create the Meeting within my personal notes database, Notes NEVER sends the Invitation to any of the listed Attendees, no matter if I edit the Meeting within Notes itself. It is basically useless.
Earlier today, I discovered the NotesDocument.Send method, which helped me a little. My Invitations are now sent to the Attendees, but when opened in Notes, are not in ‘Invitation’ format, and are instead presented as a standard plain text email, with no ‘Accept’, ‘Deny’-type buttons.
Also, if I then rerun my VB routine a second time, I get a “-2147217461 - Database Open Failed (%1)” error - not helpful. Removing the call to Send() eliminates the error.
So I ask:
-
Do I have to use the Send() method to get the Invitations sent out? If so, any ideas about this “-214…” error?
-
How do I get the sent message to appear as an Invitation rather than just a standard bloody email!?
So frustrating for something so simple!
Here is my routine:
Sub CreateNotesMeeting()
On Error GoTo ErrorHandler
Dim objNotesSession As NotesSession
Dim objNotesDbDirectory As NotesDbDirectory
Dim objNotesDatabase As NotesDatabase
Dim objNotesDocument As NotesDocument
Dim objNotesDtFrom As NotesDateTime
Dim objNotesDtTo As NotesDateTime
Dim objNotesRichTextItem As NotesRichTextItem
Set objNotesSession = New NotesSession
Call objNotesSession.Initialize
Set objNotesDbDirectory = objNotesSession.GetDbDirectory("")
Set objNotesDatabase = objNotesDbDirectory.OpenMailDatabase()
'Set objNotesDatabase = objNotesSession.GetDatabase("", "mail\amcnab.nsf")
Set objNotesDocument = objNotesDatabase.CreateDocument
Set objNotesDtFrom = objNotesSession.CreateDateTime("2004-04-21 15:00:00")
Set objNotesDtTo = objNotesSession.CreateDateTime("2004-04-21 16:00:00")
Set objNotesRichTextItem = objNotesDocument.CreateRichTextItem("Body")
'## Appointment Type - Meeting
Call objNotesDocument.ReplaceItemValue("AppointmentType", "3")
'## General Meeting Info
Call objNotesDocument.ReplaceItemValue("Form", "Appointment")
Call objNotesDocument.ReplaceItemValue("Subject", "Test Meeting 3 Subject")
'commented line replaced with mulit-line body example
'Call objNotesDocument.ReplaceItemValue("Body", strBody)
objNotesRichTextItem.AppendText ("This is line 1")
objNotesRichTextItem.AddNewLine
objNotesRichTextItem.AppendText ("This is line 2")
Call objNotesDocument.ReplaceItemValue("Location", "Test Meeting 3 Location")
Call objNotesDocument.ReplaceItemValue("Room", "Test Meeting 3 Room")
'## Who sent/created/chairs the Meeting
Call objNotesDocument.ReplaceItemValue("From", objNotesSession.UserName)
Call objNotesDocument.ReplaceItemValue("Chair", objNotesSession.UserName)
'## Time of meeting-related stuff
Call objNotesDocument.ReplaceItemValue("STARTDATETIME", objNotesDtFrom)
Call objNotesDocument.ReplaceItemValue("EndDateTime", objNotesDtTo)
Call objNotesDocument.ReplaceItemValue("CalendarDateTime", objNotesDtFrom)
Call objNotesDocument.ReplaceItemValue("StartTime", objNotesDtFrom)
Call objNotesDocument.ReplaceItemValue("EndTime", objNotesDtTo)
Call objNotesDocument.ReplaceItemValue("StartDate", objNotesDtFrom)
Call objNotesDocument.ReplaceItemValue("EndDate", objNotesDtTo)
'## Attendee-related data
Dim arrRequiredAttendeeName() As String
Dim arrRequiredAttendeeNameAndEmail() As String
arrRequiredAttendeeName = Split("XXX@XXX.com", ";", -1)
Call objNotesDocument.AppendItemValue("RequiredAttendees", arrRequiredAttendeeName)
Call objNotesDocument.AppendItemValue("AltRequiredNames", arrRequiredAttendeeName)
'Call objNotesDocument.AppendItemValue("INetRequiredNames", arrRequiredAttendeeNameAndEmail)
Call objNotesDocument.ReplaceItemValue("StorageRequiredNames", ".")
Call objNotesDocument.AppendItemValue("SendTo", arrRequiredAttendeeName)
Call objNotesDocument.AppendItemValue("NoticeType", "I")
'## System variables
Call objNotesDocument.ReplaceItemValue("$UpdatedBy", objNotesSession.UserName)
Call objNotesDocument.ReplaceItemValue("_ViewIcon", 158)
'Call objNotesDocument.ComputeWithForm(False, False)
Call objNotesDocument.Send(True, arrRequiredAttendeeName)
Call objNotesDocument.Save(True, True)
Set objNotesRichTextItem = Nothing
Set objNotesDtTo = Nothing
Set objNotesDtFrom = Nothing
Set objNotesDocument = Nothing
Set objNotesDatabase = Nothing
Set objNotesDbDirectory = Nothing
Set objNotesSession = Nothing
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
End Sub