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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| Sub EnvoiMail_anniversaire_fete()
Application.ScreenUpdating = False
Dim ObjOutlook As New Outlook.Application
Dim oBjMail As Outlook.MailItem
Dim texte_anniv As String, texte_fete As String, nom As String, nom2 As String, ajout As String
Dim ton_mail As String
Dim i As Integer
Dim derlign As Integer
Dim anniv As Date
Dim fete As Date
On Error Resume Next
derlign = Worksheets("Feuil1").Range("A65536").End(xlUp).Row
For i = 4 To derlign
anniv = Range("D" & i).Value
texte_anniv = "<br><font style='font-family: Calibri;font-size: 11pt ;" & _
"' font color=black>Joyeux Anniversaire" & _
"</FONT>"
Set ObjOutlook = New Outlook.Application
Set oBjMail = ObjOutlook.CreateItem(olMailItem)
ton_mail = "moi@live.fr" 'ton adresse mail à mettre ici
If anniv <= "10" Then
With oBjMail
.Display
.To = Range("G" & i).Value
.CC = ton_mail
'.BCC = ""
.Subject = "Anniversaire"
.HTMLBody = texte_anniv & " " & .HTMLBody
.Display
'.Send
End With
End If
Next i
Set oBjMail = Nothing
Set ObjOutlook = Nothing
For i = 4 To derlign
fete = Range("F" & i).Value
texte_fete = "<br><font style='font-family: Calibri;font-size: 11pt ;" & _
"' font color=black>Joyeuse Fête" & _
"</FONT>"
Set ObjOutlook = New Outlook.Application
Set oBjMail = ObjOutlook.CreateItem(olMailItem)
If fete <= "10" Then
With oBjMail
.Display
.To = Range("G" & i).Value
.CC = ton_mail
'.BCC = ""
.Subject = "Fête"
.HTMLBody = texte_fete & " " & .HTMLBody
.Display
'.Send
End With
End If
Next i
Set oBjMail = Nothing
Set ObjOutlook = Nothing
On Error GoTo 0
End Sub |
Partager