Envoie par mail d'une ou plusieurs pièces jointes

Fermé
Reggs7 Messages postés 26 Date d'inscription vendredi 21 décembre 2018 Statut Membre Dernière intervention 9 septembre 2019 - 9 sept. 2019 à 15:05
cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 - 9 sept. 2019 à 15:13
Bonjour,
J'utilise ce code dans un fichier qui produit un relevé mensuel des dépenses des employés et parfois ils ont aucune ou plusieurs pièces justificatives à joindre.
Malheureusement la macro permet d'acheminer qu'une seule pièce, pouvez-vous m'orienter sur les commandes à utiliser pour en joindre plus d'une.


retour = MsgBox("Souhaitez vous joindre un fichier ?", vbQuestion + vbYesNo, "joindre un fichier")
If retour = vbYes Then
fichier = Application.GetOpenFilename("tous les fichiers(*.*),*.*")

Set envoiecourriel = ThisWorkbook.Sheets("lettre_courriel")
ActiveSheet.Range("D8:t122").Select
ActiveWorkbook.EnvelopeVisible = True

With ActiveSheet.MailEnvelope
.Item.To = envoiecourriel.Range("ad1").Value
.Item.Subject = envoiecourriel.Range("ad2").Value
.Item.cc = envoiecourriel.Range("ad3").Value
.Item.attachments.Add fichier
.Item.send 'envoie
End With
Else

Set envoiecourriel = ThisWorkbook.Sheets("lettre_courriel")
ActiveSheet.Range("D8:t122").Select
ActiveWorkbook.EnvelopeVisible = True

With ActiveSheet.MailEnvelope
.Item.To = envoiecourriel.Range("ad1").Value
.Item.Subject = envoiecourriel.Range("ad2").Value
.Item.cc = envoiecourriel.Range("ad3").Value
.Item.send 'envoie
End With
End If

Configuration: Windows / Internet Explorer 11.0
A voir également:

1 réponse

cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 728
Modifié le 9 sept. 2019 à 15:15
Bonjour,

Par politesse tu aurais pu donner suite ici:

https://forums.commentcamarche.net/forum/affich-36196961-macro-redemarrage-du-fichier

pour ta question une recherche sur Google de 10 secondes t'aurait donné ceci:


https://www.extendoffice.com/documents/excel/4719-excel-macro-send-multiple-attachment.html


0