Ajout pièce jointe Excel avec numéro chrono
Bonjour,
Je débute en macro
Je voudrais faire en sorte que ma macro envoie des mails automatiques avec une pièce jointe
Par contre la pièce jointe sera a chaque fois avec un numéro chrono diffèrent et dans un dossier différent (mais la racine du dossier est la même)
Ci joint la macro pour envoi mail qui marche :
Code:
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
| Sub Envoimail()
Set Lemail = CreateObject("Outlook.application") ' Creation d'un objet Outlook
Dim Ligne As Integer
Set Lemail = CreateObject("Outlook.Application") 'création d'un objet Outlook
For Ligne = 2 To 400
If Range("b" & Ligne) = "A lancer" Then
With Lemail.CreateItem(olMailItem)
.Subject = "Chiffrage TS" & Range("c" & Ligne)
.To = Range("ax" & Ligne).Value
.Body = Range("bk1")
.CC = Range("ay" & Ligne).Value
.Attachments.Add "C:\Users\A6195429\Desktop\TEMPORAIRE\a supprimer\ESSAI\TS1B\TS1B.xlsx"
.Display
End With
End If
Range("b" & Ligne) = "Envoyé à l'EE"
Next Ligne
End Sub |