Creer un Mail depuis VBA Excel 2013 avec plusieurs fichiers attachés

escouger

XLDnaute Occasionnel
Bonjour,
J'aurai besoin d'un coup de pouce pour m'aider à trouver comment envoyer au sein d'un seul mail crée dans excel 2 fichiers attachés.
Cela marche parfaitement avec 1 seul fichier attaché mais, en en citant 2, seul le premier est envoyé.
Merci d'avance de votre aide.
GE
Voir ci-dessous mon code:
_________________________________________________________________________
Partie appelante:
messag1 = "_MAJ Planning "
messag2 = "_Envoi pour MAJ et affichages "
Nmail1 = "scaraboux@orange.fr"
Call Envoyer_Mail_Outlook(file_test_resul, file_testpdf, Nmail1)
Partie appelée:
Sub Envoyer_Mail_Outlook(Nom_Fichier, nom_fichierpdf, nmailx)
Dim ObjOutlook As New Outlook.Application
Dim oBjMail

Set ObjOutlook = New Outlook.Application
Set oBjMail = ObjOutlook.CreateItem(olMailItem)

If Nom_Fichier = "" Then Exit Sub
With oBjMail
.To = nmailx
.Subject = messag1
.Body = messag2
.Attachments.Add Nom_Fichier
.Attachments.Add nom_fichierpdf ' Ce fichier ne se retrouve pas attaché dans le mail
.Display '
.Send
End With
' ObjOutlook.Quit
Set oBjMail = Nothing
Set ObjOutlook = Nothing
End Sub
 

Lone-wolf

XLDnaute Barbatruc
Bonjour escouger

Code:
Sub EnvoiMail()
Dim i As Long, x As Long, Chemin As String, Fichiers

Set ObjOutlook = New Outlook.Application

Set oBjMail = ObjOutlook.CreateItem(olMailItem)
Chemin = "C:\Users\" & Environ("Username") & "\Doc Pdf\"   ' À modifier
x = 1
With oBjMail
.To = nmailx
.Subject = messag1
.Body = messag2
For i = 1 To 2
x = x + 1
Fichiers = Feuil1.Cells(x, 13) ' Colonne M - cellules 2 et 3 - nom sans extension
.Attachments.Add Chemin & Fichiers & ".pdf"
Next i
.Display
End With

Set oBjMail = Nothing
Set ObjOutlook = Nothing
End Sub
 
Dernière édition:

escouger

XLDnaute Occasionnel
Bonjour escouger

Code:
Sub EnvoiMail()
Dim i As Long, x As Long, Chemin As String, Fichiers

Set ObjOutlook = New Outlook.Application

Set oBjMail = ObjOutlook.CreateItem(olMailItem)
Chemin = "C:\Users\" & Environ("Username") & "\Doc Pdf\"   ' À modifier
x = 1
With oBjMail
.To = nmailx
.Subject = messag1
.Body = messag2
For i = 1 To 2
x = x + 1
Fichiers = Feuil1.Cells(x, 13) ' Colonne M - cellules 2 et 3 - nom sans extension
.Attachments.Add Chemin & Fichiers & ".pdf"
Next i
.Display
End With

Set oBjMail = Nothing
Set ObjOutlook = Nothing
End Sub
 

Membres actuellement en ligne

Statistiques des forums

Discussions
312 084
Messages
2 085 194
Membres
102 811
dernier inscrit
caroline29260