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
| Private Sub Ajout1_Click()
If Not (isMailPerso(UserForm1.TextBox1.Text)) Then
Call MsgBox("Ceci est un destinataire Professionnel" & Chr(10) & _
"Veuillez saisir l'adresse mail dans la rubrique appropriée", vbExclamation + vbOKOnly)
Exit Sub
End If
'teste si un texte a été entré, si non, le programme averti l'utilisateur et s'arrête
If UserForm1.TextBox1.Text = "" Then
MsgBox "Vous n'avez rien saisi;" & Chr(10) & "Veillez entrer un mail! "
Exit Sub
End If
For i = 1 To 10000
If Cells(i, 1) = "" Then Exit For
Next
'insertion de la valeur de la zone de texte (textbox1 représentant le nom de la zone de texte)
Cells(i, 1) = TextBox1.Text
MsgBox "Enregistrement de l'adresse Mail créé avec succès"
End Sub
Private Sub Ajout2_Click()
If (isMailPerso(UserForm1.TextBox2.Text)) Then
Call MsgBox("Ceci est un destinataire NON professionnel" & Chr(10) & _
"Veuillez saisir l'adresse mail dans la rubrique appropriée", vbExclamation + vbOKOnly)
Exit Sub
End If
'teste si un texte a été entré, si non, le programme averti l'utilisateur et s'arrête
If UserForm1.TextBox2.Text = "" Then
MsgBox "Vous n'avez rien saisi;" & Chr(10) & "Veillez entrer un mail! "
Exit Sub
End If
For i = 1 To 10000
If Cells(i, 1) = "" Then Exit For
Next
'insertion de la valeur de la zone de texte (textbox1 représentant le nom de la zone de texte)
Cells(i, 1) = TextBox2.Text
MsgBox "Enregistrement de l'adresse Mail créé avec succès"
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub TextBox1_Change()
Sheets("Mail Personnel").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = TextBox1
End Sub
Private Sub TextBox2_Change()
Sheets("Mail Professionel").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = TextBox2
End Sub
Function isMailPerso(destinataire As String) As Boolean
Dim ISPPerso() As String
ISPPerso = Split("yahoo;gmail;hotmail;live;voila;laposte;aol;bouygtel;crocomail;caramail", ";")
isMailPerso = False
Dim i As Integer
For i = 0 To UBound(ISPPerso)
If InStr(1, LCase(destinataire), "@" & ISPPerso(i)) > 0 Then
isMailPerso = True
Exit For
End If
Next i
End Function |
Partager