Bonjour,
J'ai récupéré le code suivant qui marche très bien, mais je cherche désespérement à insérer dans le nouveau message qui est lancée à avec les paramètres pré-rempli par le programme, un fichier joint.
Quelqu'un pourrait-il me dire que doive-je rajouter dans ce code pour ajouter un fichier joint au mail.
Merci
-----------------------------
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Public Sub SendMail(Optional Address As String, Optional Subject As String, Optional Body As String, Optional CC As String, Optional BCC As String)
Dim strCommand As String
'Construction du message
'Sujet du message
If Len(Subject) Then strCommand = "?subject=" & Subject
'Corps du message
If Len(Body) Then strCommand = strCommand & "&body=" & Body
'Copie du message (adresse email attendue)
If Len(CC) Then strCommand = strCommand & "&cc=" & CC
'Copie cachée du message
If Len(BCC) Then strCommand = strCommand & "&bcc" & BCC
'Ajout de l'adresse email à la ligne de commande
strCommand = "mailto:" & Address & strCommand
'Execution de la commande via l'API
Call ShellExecute(Me.hwnd, "open", strCommand, vbNullString, vbNullString, SW_SHOWNORMAL)
End Sub
'Bouton de commande pour déclencher l'envoi du mail
Private Sub Command1_Click()
SendMail "adresse", "sujet", "message", "copie", "copie cachée"
End Sub
-----------------------------------------