Pour Excel ou Access c'est la meme methode.
Vous devez utiliser les objets OLE via la fonction GetObject() qui vous permettra d'ouvrir une cession Notes. Verifier les references afin que les librairies suivantes soient bien selectionnees : Microsoft DAO 3.6 Microsoft ActiveX Data
je vous joins le code a utiliser pour envoyer un email via Notes avec piece jointe svp.
------------------------------------------------------------
Function SendLotusNotesMail(sSubject As String, sComments As String, _ sTo() As Variant, sCC() As Variant, sBCC() As Variant, _ sFile() As String) As Boolean
On Error GoTo Err_SendLotusNotesMail
Dim NotesSession As Object Dim NotesDB As Object Dim NotesMailDoc As Object Dim NotesAttach As Object Dim NotesRTF As Object Dim NotesDocID As String Dim i As Integer Dim sAttachment As String Const EMBED_FILE = 1454 Set NotesSession = GetObject("", "Notes.NotesSession") Set NotesDB = NotesSession.GETDATABASE("", "") ' Default Database NotesDB.OPENMAIL ' Open Lotus Notes Mail
Set NotesMailDoc = NotesDB.CREATEDOCUMENT NotesMailDoc.Form = "Memo" NotesMailDoc.Subject = sSubject NotesMailDoc.SendTo = sTo If sCC(0) <> "" Then NotesMailDoc.Copyto = sCC If sBCC(0) <> "" Then NotesMailDoc.BlindCopyTo = sBCC NotesMailDoc.FROM = NotesSession.COMMONUSERNAME NotesMailDoc.Body = sComments NotesMailDoc.SAVEMESSAGEONSEND = True ' Attach files If Not IsNull(sFile(0)) And sFile(0) <> "" Then For i = 0 To UBound(sFile) If Not IsNull(sFile(i)) And sFile(i) <> "" Then ' create unique Attachment name for each file sAttachment = "Attachment " & i Set NotesRTF = NotesMailDoc.CREATERICHTEXTITEM(sAttachment) Set NotesAttach = NotesRTF.EMBEDOBJECT(EMBED_FILE, sAttachment, sFile(i)) End If Next i End If NotesMailDoc.SEND False ' No form to attach SendLotusNotesMail = True ' successfully sent Exit_SendLotusNotesMail: On Error Resume Next
' Cleanup objects Set NotesAttach = Nothing Set NotesRTF = Nothing Set NotesMailDoc = Nothing Set NotesDB = Nothing Set NotesSession = Nothing Exit Function Err_SendLotusNotesMail: SendLotusNotesMail = False MsgBox Err.Description Resume Exit_SendLotusNotesMail
End Function --------------------------------------------------------------
Bonne continuation ...
SCOTTISH
|