There are several responses here so I don't know which you mean. In this, .Send should suffice.
Option Explicit
Sub test()
Dim lErr As ErrObject
SendNotesMail _
"PMP Handbook5", _
"c:\t.pdf", _
"khobson@work.org,khobson@aaahawk.com", _
"Click file: " & vbCrLf & _
"file://u:\Material\pmp\PMP%20Handbook.pdf" & vbCrLf & _
"or, open the attachement.", , lErr
If lErr.Number <> 0 Then MsgBox lErr.Number & vbCrLf & lErr.Description
End Sub
'Escape characters, %20=space, http://everything2.com/node/1350052
'Similar to: Brian Walters, http://www.ozgrid.com/forum/showthread.php?t=67089
Public Sub SendNotesMail(Subject As String, Attachment As String, _
ByVal Recipient As String, _
BodyText As String, _
Optional SaveIt As Boolean = True, _
Optional ByRef lErr As ErrObject)
'lErr is used when using the Sub in a batch process,
'to handle instances where an error appears
'Example of use:
'SendNotesMail "The Subject", "C:\My Documents\TestFile.txt", _
"john@doe.com, jane@doe.com", _
"This is the body text, can be longer", True, lErr
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim ArRecipients() As String 'Array of recipients
Dim i As Long 'Counter
Dim oBody As Object 'Body of text in for rich text format
'Early Bind - Tools > Reference > Lotus Notes Automation Classes, notes32.tlb
'Dim ln As lotus.NOTESSESSION
'Set ln = CreateObject("Notes.NotesSession")
'Dim db As lotus.NOTESDATABASE
'Set db = ln.GETDATABASE("", "mail\username.nsf")
'Dim mDoc As lotus.NOTESDOCUMENT
'Set mDoc = db.CREATEDOCUMENT
'Create an array of recipients (Separated by commas)
ArRecipients() = Split(Recipient, ",")
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
On Error GoTo err_h
'Open the mail database in notes
UserName = Session.UserName
'************** ADD YOUR username.
Set Maildb = Session.GETDATABASE("", "mail\khobson.nsf")
If Maildb.IsOpen = False Then
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = ArRecipients
MailDoc.Subject = UCase(Subject)
'MailDoc.Body = UCase(BodyText)
Set oBody = MailDoc.CREATERICHTEXTITEM("Body")
oBody.APPENDTEXT BodyText
'This is supposed to be the property, but works
'on some systems only
'without an apparent reason of failure
MailDoc.SAVEMESSAGEONSEND = SaveIt
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
End If
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 1
MailDoc.Save True, True, False
'Clean Up
err_h:
Set lErr = Err
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub