Sub BoucleDestinataires2()
Dim i As Long
i = 2
While ThisWorkbook.Sheets("Pharma").Cells(i, 1) <> vbNullString
Call Macro2(ThisWorkbook.Sheets("Pharma").Cells(i, 1), ThisWorkbook.Sheets("Pharma").Cells(i, 2), ThisWorkbook.Sheets("Pharma").Cells(i, 3), ThisWorkbook.Sheets("Pharma").Cells(i, 4), ThisWorkbook.Sheets("Pharma").Cells(i, 5), ThisWorkbook.Sheets("Pharma").Cells(i, 6), ThisWorkbook.Sheets("Pharma").Cells(i, 7), ThisWorkbook.Sheets("Pharma").Cells(i, 8), ThisWorkbook.Sheets("Pharma").Cells(i, 9), ThisWorkbook.Sheets("Pharma").Cells(i, 10), ThisWorkbook.Sheets("Pharma").Cells(i, 11), ThisWorkbook.Sheets("Pharma").Cells(i, 12), ThisWorkbook.Sheets("Pharma").Cells(i, 13))
i = i + 1
Wend
End Sub
Sub Macro2(Destinataire2 As String, CC As String, BCC As String, Objet As String, Chemin1 As String, Chemin2 As String, Chemin3 As String, Chemin4 As String, Chemin5 As String, Chemin6 As String, Chemin7 As String, Chemin8 As String, Chemin9 As String)
Dim OutMail As Object
Dim oApp As Outlook.Application
Dim oEmail As MailItem
Dim colAttach As Outlook.Attachments
Dim oAttach As Outlook.Attachment
Dim olkPA As Outlook.PropertyAccessor
Const PR_ATTACH_CONTENT_ID = "http://schemas.microsoft.com/mapi/proptag/0x3712001F"
'create new Outlook MailItem
Set oApp = CreateObject("Outlook.Application")
Set oEmail = oApp.CreateItem(olMailItem)
'add graphic as attachment to Outlook message
'change path to graphic as needed
Set colAttach = oEmail.Attachments
Set oAttach = colAttach.Add("C:\Users\RC1194\Desktop\Projet\Pharmo\Macro\Mail_reporting.png")
Set olkPA = oAttach.PropertyAccessor
.Attachments.Add Chemin1
' oEmail.Attachments.Add Chemin2
' oEmail.Attachments.Add Chemin3
olkPA.SetProperty PR_ATTACH_CONTENT_ID, "Mail_reporting.png"
oEmail.Close olSave
'change the src property to 'cid:your picture filename'
'it will be changed to the correct cid when its sent.
oEmail.HTMLBody = "<BODY><IMG src=""cid:Mail_reporting.png""> </BODY>"
'oEmail.Save
oEmail.To = Destinataire2
oEmail.CC = CC
oEmail.BCC = BCC
oEmail.Subject = Objet
'oEmail.Send
' oEmail.Save
' oEmail.To = "anthony@hotmail.com"
' oEmail.Subject = "test"
oEmail.Send
Set oEmail = Nothing
Set colAttach = Nothing
Set oAttach = Nothing
Set oApp = Nothing
End Sub