Bonjour,

j'ai crée un formulaire de saisie avec un bouton qui envoie un mail automatiquement par rapport à une adresse mail saisie.
J'ai créé un message pour confirmer que le mail est envoyé.
Si je saisie une adresse mail avec une erreur de frappe j'aimerai un message pour me confirmer que le message n'a pas été envoyé.
Ci-dessous le message d'erreur qui apparaît

Nom : Annotation 2020-02-17 171911.png
Affichages : 144
Taille : 6,3 Ko

Je met mon code VBA pour la procédure d'envoie du mail

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Private Sub Mail_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim strMsg As String
Dim strDest As String
 
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
 
strMsg = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"
strMsg = strMsg & "<html xmlns='http://www.w3.org/1999/xhtml'>"
strMsg = strMsg & "<body>"
strMsg = strMsg & "<p>Bonjour,"
strMsg = strMsg & "<table width='800px' border='1' cellpadding='0'>"
strMsg = strMsg & "<tr>"
strMsg = strMsg & "<td ><p align='center'><strong>Date</strong></p></td>"
strMsg = strMsg & "<td ><p align='center'><strong>Air Waybill</strong></p></td>"
strMsg = strMsg & "<td ><p align='center'><strong>Expéditeur</strong></p></td>"
strMsg = strMsg & "<td ><p align='center'><strong>Destinataire</strong></p></td>"
strMsg = strMsg & "<td ><p align='center'><strong>Nombre de colis</strong></p></td>"
strMsg = strMsg & "<td ><p align='center'><strong>Format colis</strong></p></td>"
strMsg = strMsg & "<td ><p align='center'><strong>Localisation</strong></p></td>"
strMsg = strMsg & "<td ><p align='center'><strong>Commentaires</strong></p></td>"
strMsg = strMsg & "</tr>"
strMsg = strMsg & "<tr>"
strMsg = strMsg & "<td><p align='center'>" & Format(txtDatederéception, "dd/MMM/yyyy") & "</p></td>"
strMsg = strMsg & "<td><p align='center'>" & txtNuméroduColis & "</p></td>"
strMsg = strMsg & "<td><p align='center'>" & txtExpéditeur & "</p></td>"
strMsg = strMsg & "<td><p align='center'>" & txtDestinataire & "</p></td>"
strMsg = strMsg & "<td><p align='center'><strong>" & Format(txtNombredecolis) & "</strong></p></td>"
strMsg = strMsg & "<td><p align='center'>" & txtFormatColis & "</p></td>"
strMsg = strMsg & "<td><p align='center'>" & txtLocalisation & "</p></td>"
strMsg = strMsg & "<td><p align='center'>" & txtCommentaire & "</font></p></td>"
strMsg = strMsg & "</tr>"
strMsg = strMsg & "</table>"
 
strDest = txtemail
 
With OutMail
 .To = strDest
 .Subject = "..."
 .HTMLBody = strMsg
 .Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
MsgBox "Votre mail a été envoyé", vbInformation + vbOKOnly, "confirmation envoie"
End Sub