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 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| Sub UseLotus()
Dim Session As NotesSession
Dim db As Object
Dim doc As Object
Dim rtitem As Object
Dim object As Object
Dim fs As Object
Dim Principaux(2) As String
Dim Copies(3) As String
Dim dir As Object
Dim inti As Integer
Dim passwd As String
On Error GoTo TraiteErreur
'Demande le password Lotus(Dans le cas ou la session necessite un passwd)
passwd = InputBox("Entrer votre password Lotus:", "Password")
' Création de la session Notes
Set Session = CreateObject("Lotus.NotesSession") ' Session n'est pas initialisé
'Ouverture d'une session NOTES
Call Session.Initialize(passwd) 'si pas de passwd pas de parametre pour initialize
Set dir = Session.GETDBDIRECTORY("") 'FranceServer1/DCI/BME/Omnia Group
Set db = dir.OpenMailDatabase
' Création d'un document
Set doc = db.CREATEDOCUMENT
'affectation du type mail
Call doc.APPENDITEMVALUE("Form", "Memo")
Call doc.APPENDITEMVALUE("Sendto", "mmmm@msn.com")
Call doc.APPENDITEMVALUE("subject", "Alerte !")
doc.SAVEMESSAGEONSEND = saveit 'sauvegarde du mail à l envoi
Set rtitem = doc.createRichTextItem("Body")
Dim nom As String
nom = ThisWorkbook.FullName
'Attachement du classeur au mail
Set object = rtitem.embedObject(1454, "", nom, "")
Call doc.Send(True)
Set object = Nothing
Set rtitem = Nothing
Set doc = Nothing
Set db = Nothing
Set Session = Nothing
Exit Sub
TraiteErreur:
MsgBox "Erreur Critique durant l envoi .", vbCritical, "Error"
Set object = Nothing
Set rtitem = Nothing
Set doc = Nothing
Set db = Nothing
Set Session = Nothing
Set fs = Nothing
End Sub |
Partager