Bonsoir le Forum,
J'aurai besoin de vos lumières...
J'ai une macro me permettant d'envoyer un mail en y joignant une PJ ou non.
Mon souci est que je ne peux joindre qu'1 PJ alors que j'ai parfois besoin d'en joindre plusieurs comme je peux le faire avec Outlook.
Pourriez-vous sm'aider svp ?
Ci-joint le code en question :
	
	
	
	
	
		
Merci !!!
	
		
			
		
		
	
				
			J'aurai besoin de vos lumières...
J'ai une macro me permettant d'envoyer un mail en y joignant une PJ ou non.
Mon souci est que je ne peux joindre qu'1 PJ alors que j'ai parfois besoin d'en joindre plusieurs comme je peux le faire avec Outlook.
Pourriez-vous sm'aider svp ?
Ci-joint le code en question :
		VB:
	
	
	Public Sub PrEnvoiMailPJ(deb As Integer, fin As Integer)
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim Destinataire As String
Dim PJ As String
Dim i As Integer
   
If MsgBox("Voulez-vous joindre un document à votre mail ?", vbYesNo + vbQuestion) = vbYes Then
    PJ = Application.GetOpenFilename("Tous les fichiers (*.*),*.*")
        If PJ <> "" Then
        MsgBox "Opération annulée !" & Chr(10) & "Cliquer à nouveau pour joindre une nouvelle PJ ou envoyer votre mail", vbInformation, "Information"
        Exit Sub
        End If
    MsgBox "Mail en préparation..." & Chr(10) & "xxxxxx", vbExclamation
        With Sheets("Feuil1")
            For i = deb To fin
                Destinataire = .Cells(i, "E")
                Set OutlookApp = CreateObject("outlook.application")
                Set OutlookMail = OutlookApp.createitem(0)
                    With OutlookMail
                        .Subject = "xxxxx - " + UserForm1.TextBox3.Value
                        .To = Destinataire
                        .CC = UserForm1.TextBox2.Value
                        .Body = UserForm2.TextBox1.Value
                        .attachments.Add PJ
                        .Display
                        '.send
                    End With
            Next i
        End With
Else
    MsgBox "Mail en préparation..." & Chr(10) & "xxxxxx", vbExclamation
        With Sheets("Feuil1")
            For i = deb To fin
            Destinataire = .Cells(i, "E")
            Set OutlookApp = CreateObject("outlook.application")
            Set OutlookMail = OutlookApp.createitem(0)
                With OutlookMail
                    .Subject = "xxxx - " + UserForm1.TextBox3.Value
                    .To = Destinataire
                    .CC = UserForm1.TextBox2.Value
                    .Body = UserForm2.TextBox1.Value
                    .Display
                    '.send
                End With
            Next i
        End With
End If
End Sub
	Merci !!!