1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Datedujour = Format(Now, "yymmdd")
Dim Dpt As Long
Dpt = InputBox(Dpt, "Veuillez renseigner le département cible du publipostage")
Dossier = "S:\XXXX\Publipostage\Fichiers_" & Datedujour & "\" & Rep
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
Dim LastLig As Long, Test As String
Test = InputBox(Test, "S'agit-il du Test pré envoi OUI / NON")
If Test = "OUI" Then
Sheets("Test").Select
Else
Sheets("Etab_Publipostage").Select
End If
LastLig = Range("A5000").End(xlUp).Row
For j = 2 To LaestLig
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Cells(j, 4)
'
.Subject = "zzzz"
.Body = "À l'attention de Madame ou Monsieur du " & Cells(j, 2) & " à " & Cells(j, 3) & " (" & Cells(j, 1) & ")" & Chr(13) _
& Chr(13) _
& Chr(13) & "Madame, Monsieur," & Chr(13) _
& Chr(13) & "...." & Chr(13) _
& Chr(13) & "Vous trouverez ci-joint un document Excel consignant toutes les incohérences constatées. L'onglet Définitions contient le détail des incohérences et des actions à mener" & Chr(13) _
& Chr(13) & "Merci de vérifier et éventuellement corriger, ces informations. Si ces informations sont correctes, merci de nous le confirmer par retour de mail." & Chr(13) _
& Chr(13) & "N'hésitez pas à nous solliciter pour toutes questions." & Chr(13) _
& Chr(13) & "En vous remerciant par avance," & Chr(13) _
& Chr(13) & "Cordialement," & Chr(13) _
& Chr(13) & "..."
.Attachments.Add ("" & Dossier & "\" & Cells(j, 5) & ".xls")
.send
End With
On Error GoTo 0
Set OutMail = Nothing
Next j
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
MsgBox ("Les mails sont bien envoyés !") |
Partager