1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| Public Sub MS_SendMessageLotusNotes(vSendTo As Variant, strSubject As String, _
strBody As String, Optional vCC As Variant = "", _
Optional strAttachment As String = "", _
Optional bKeepTrack As Boolean = False)
'rem : vSendTo is a string var in case of a unique recipient
' a variant array of string in a case of a mailing list
On Error GoTo MS_SendMessageLotusNotes_error
Dim objNoteSession As Object
Dim objDbNotes As Object
Dim objMailDoc As Object
Dim objRichTextFile As Object
Dim objAttachment As Object
Set objNoteSession = CreateObject("Notes.Notessession")
Set objDbNotes = objNoteSession.GETDATABASE("", "")
If objDbNotes.IsOpen Then
' nop
Else
Call objDbNotes.OPENMAIL
End If
Set objMailDoc = objDbNotes.CREATEDOCUMENT
objMailDoc.Form = "Memo"
objMailDoc.SendTo = vSendTo ' recipient
objMailDoc.CopyTo = vCC
objMailDoc.Subject = strSubject
objMailDoc.Body = strBody
objMailDoc.SaveMessageOnSend = bKeepTrack ' backup Message dans le sendTo
If strAttachment <> "" Then
Set objRichTextFile = objMailDoc.CreateRichTextItem("Attachment")
Set objAttachment = objRichTextFile.EmbedObject(1454, "", strAttachment, "Attachment")
' objMailDoc.CreateRichTextItem ("Attachment")
End If
objMailDoc.PostedDate = Now()
objMailDoc.SEND False, vSendTo
MS_SendMessageLotusNotes_exit:
Set objNoteSession = Nothing
Set objDbNotes = Nothing
Set objMailDoc = Nothing
Set objAttachment = Nothing
Set objRichTextFile = Nothing
Exit Sub
MS_SendMessageLotusNotes_error:
MsgBox "Error. Lotus may be closed" & vbCr & Error$, vbCritical
Resume MS_SendMessageLotusNotes_exit
End Sub |
Partager