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
| Private Sub UseLotus()
Dim Session As Object
Dim Dir As Object
Dim Doc As Object
Dim Workspace As Object
Dim EditDoc As Object
Dim stAttachment As String
Dim noAttachment As Object
On Error GoTo TraiteErreur
fin = Feuil1.Range("a1").End(xlDown).Row
For i = 2 To fin
'Création de la session Notes
Set Workspace = CreateObject("Notes.NotesUIWorkspace")
Set Session = CreateObject("notes.NOTESSESSION")
Set Dir = Session.GetDatabase("", "")
Call Dir.OPENMAIL
'Creation d'un document
Set Doc = Dir.CreateDocument
Doc.Form = "Memo"
Doc.Subject = Feuil1.Range("d" & i).Value
Doc.SendTo = Feuil1.Range("c" & i).Value
Doc.Body = Feuil1.Range("e" & i).Value
stAttachment = Feuil1.Range("f" & i).Value
'Affichage du mail dans Lotus Notes
Set EditDoc = Workspace.EditDocument(False, Doc)
Call Doc.Send(False)
Set Session = Nothing
Set Dir = Nothing
Set Doc = Nothing
Set Workspace = Nothing
Set EditDoc = Nothing
Next
TraiteErreur:
MsgBox "Problème de création du mail", vbCritical, "Error"
Set Session = Nothing
Set Dir = Nothing
Set Doc = Nothing
Set Workspace = Nothing
Set EditDoc = Nothing
End Sub |
Partager