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
|
'Il faut activer la référence "Microsoft Outlook Library" Avant de lancer cette macro,
' Dans l'éditeur VBA: Faire Menu / Tools / Reference / Cocher "Microsoft Outlook Library"
Sub Envoyer_Mail_Outlook()
Dim ObjOutlook As New Outlook.Application
Dim oBjMail
Dim Nom_Fichier As String
Set ObjOutlook = New Outlook.Application
Set oBjMail = ObjOutlook.CreateItem(olMailItem)
'---------------------------------------------------------
'Ou bien entrer le path et nom du fichier autrement
Nom_Fichier = "C:\Chemin\NomFichier.ext"
If Nom_Fichier = "" Then Exit Sub
'---------------------------------------------------------
With oBjMail
.To = "LeClient@gmail.com" ' le destinataire
.Subject = "Ici c'est l'objet" ' l'objet du mail
.Body = "Ici le texte du mail " 'le corps du mail ..son contenu
.Attachments.Add Nom_Fichier
.Display ' Ici on peut supprimer pour l'envoyer sans vérification
.Send
End With
ObjOutlook.Quit
Set oBjMail = Nothing
Set ObjOutlook = Nothing
End Sub |
Partager