Sub creer_TEST()
[A1:D1] = Array("Email", "Objet", "Message", "Pièce jointe") ' juste pour l'exemple
[A2:A10] = "=""nom""&ROW()-1&"".prenom@domain""&ROW()-1&"".""&CHOOSE(MOD(ROW()-1,3)+1,""fr"",""org"",""com"")"
[A2:A10] = [A2:A10].Value
[B2] = "Objet1": [B2].AutoFill [B2:B10], xlFillDefault
[C2] = "Ceci est un Message1": [C2].AutoFill Destination:=Range("C2:C10"), Type:=xlFillDefault
[D2:D10] = "C:\Windows\system.ini"
End Sub
Sub Test_Emailing()
'Dans Excel, ne pas oublier d'activer Référence: Outlook
'->Outils/Références/ Microsoft Outlook XX.0 Object Library
'NB: XX: selon version Excel, on aura 12.0 ou 15.0 etc...
Dim outApp As Outlook.Application, outMail As Outlook.MailItem
Dim desti$, objet$, pijo$, mess$
Dim plg As Range, ce As Range
Set plg = Range([A2], Cells(Rows.Count, "A").End(3))
For Each ce In plg
desti = ce.Value2
objet = ce.Offset(, 1).Value2
mess = ce.Offset(, 2).Value2
pijo = ce.Offset(, 3).Value2
On Error Resume Next
Set outMail = outApp.CreateItem(0)
With outMail
.To = desti
.Subject = objet
.Body = mess
.Attachments.Add pijo
.display
End With
On Error GoTo 0
Set outMail = Nothing
Next ce
End Sub