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
| Sub mail()
'Déclaration du type variable :
Dim nb_ligne_max, i As Integer
Dim ol As Object, olmail As Object
Dim adresse_mail, adresse_mail_escalade, probleme, ndi, ref_commande, tt_clarify, formule_ordre_activation As String
Dim Insert, Signature As String
' nb_ligne_max indique le nbre ligne maximun du tableau
nb_ligne_max = Worksheets("Formulaire").Range("E2").End(xlDown).Row
'creation d'une boucle de ligne de 2 à la derniere ligne
For i = 2 To 20
Set ol = CreateObject("Outlook.Application")
Set olmail = ol.Application.CreateItem(olMailItem)
'Déclaration des variables
adresse_mail = Worksheets("Formulaire").Range("C" & CStr(i)).Value
adresse_mail_escalade = Worksheets("Formulaire").Range("D" & CStr(i)).Value
probleme = Worksheets("Formulaire").Range("A" & CStr(i)).Value
ndi = Worksheets("Formulaire").Range("E" & CStr(i)).Value
ref_commande = Worksheets("Formulaire").Range("F" & CStr(i)).Value
tt_clarify = Worksheets("Formulaire").Range("G" & CStr(i)).Value
formule_ordre_activation = "Bonjour " & ",<br/><br/> Pouvez-vous SVP envoyer un ordre d'activation pour notre commande portabilité du nd " & ndi & " ?" & "<br/><br/><br/><br/> Merci d'avance."
'Demande d'envoie d'ordre activation
If probleme = "Demande d'envoi d'ordre d'activation (Porta annu ou Porta activ)" Then
If IsError(ndi) Or ndi = "" Then
Else
With olmail
.To = adresse_mail
.cc = "cellulepnf@sfr.com"
.Subject = probleme & " // ND : " & ndi & " // Réf commande " & ref_commande & " // " & tt_clarify
.HTMLBody = formule_ordre_activation
.display
.GetInspector.CommandBars.Item("Insert").Controls("Signature").Controls(2).Execute
End With
End If
Else
End If
Next i
End Sub |
Partager