Hey Mike
I use this code with A97 and Notes 6, hopefully it will work for notes 5
You'll need to set a reference to the notes library, do a search for
notes32.tlb on your local machine, Add through Tools->References->Browse and
select the file. This appears in the references list as 'Lotus Notes
Automation Classes'
'Sends an email from Lotus Notes client
Public Function SendNotesEmail(send_to As String, subject As String, message
As String) As Integer
On Local Error GoTo err_handler
Dim session As Object
Dim datab As Object
Dim Doc As Object
Dim sMsg As String
Dim server_name As String
Dim server_folder As String
Dim database_name As String
'Set default return value
SendNotesEmail = NO_ERRORS
'Get mail-in database settings (server, path and filename)
server_name = getPreference(MAIL_SERVER)
server_folder = getPreference(MAIL_PATH)
database_name = getPreference(MAIL_DATABASE)
'Start creating email
Set session = CreateObject("Notes.NotesSession") 'create notes session
Set datab = session.GETDATABASE(server_name, server_folder & "\" &
database_name)
Call datab.OPENMAIL 'set database to
default mail database
Set Doc = datab.CREATEDOCUMENT 'notesdocument '.New
'(db) ' create a mail document
'Fill in some basic fields
Call Doc.REPLACEITEMVALUE("SendTo", send_to)
Call Doc.REPLACEITEMVALUE("Body", message)
Call Doc.REPLACEITEMVALUE("From", email_address)
Call Doc.REPLACEITEMVALUE("Subject", subject)
Call Doc.REPLACEITEMVALUE("ReplyTo", email_address)
'Save a copy of the outgoing message -- this doesn't seem to work
' Call doc.Save(True)
' doc.SAVEMESSAGEONSEND = True
'Send the email
Call Doc.SEND(False) 'send the message
Set session = Nothing ' close connection
to free memory
Set datab = Nothing
Set Doc = Nothing
Exit Function
err_handler:
SendNotesEmail = err.Number
Resume Next
End Function
If you want file attachements, add these lines before the 'CALL doc.Send
(false)' line
'We need a rich text item to attach a file (.EmbedObject method is in
RichTextItem class)
Dim rtItem As Object
Set rtItem = Doc.CREATERICHTEXTITEM(Doc, "Body")
Call rtItem.EMBEDOBJECT(1454, "", PATH & "\" & file, "Label to appear as
attachment name")
HTH