Vérifier existance mail - retour erreur

Résolu
cs_fabiano13 Messages postés 262 Date d'inscription mardi 26 février 2002 Statut Membre Dernière intervention 27 février 2012 - 10 janv. 2011 à 11:29
cs_fabiano13 Messages postés 262 Date d'inscription mardi 26 février 2002 Statut Membre Dernière intervention 27 février 2012 - 10 janv. 2011 à 12:59
Afin de vérifier l'authentification d'une personne qui travail avec nous je voudrais lui envoyer un mail.

Comment vérifier si le mail qu'il saisie est bon ? Comment récupérer l'erreur ?

D'avance merci.
Fabiano

Voici le script que j'utilise pour envoyer ce mail :

Const PourLecture = 1
Const cteAdresseSource = "contact@MaSociete.com"
Const ServeurSMTP = "smtp.MaSociete.com"

Private Sub EnvoieEmail()
Dim objMail As Object
Dim sDestination As String
Dim sPieceJointe As String
Dim msgTitre As String
Dim msgTexte As String

Dim Drapeau As Boolean

objMail = CreateObject("CDO.Message")
Drapeau = False
sDestination = "destinataire@MaSociete.com"
msgTitre = "Automatisme"
msgTexte = "Bonjour," & vbLf & "Corps du message"
sPieceJointe = "D:\Monfichier.txt"
Drapeau = True

With objMail
.From = cteAdresseSource
.To = sDestination
.Subject = msgTitre
If (sPieceJointe <> "") Then
.TextBody = msgTexte & vbLf & "Pièce jointe incluse : " & vbLf
Else
.TextBody = msgTexte & vbCrLf & "Aucune Pièce jointe" & vbCrLf
End If
.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ServeurSMTP
.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Update()

If ((sPieceJointe <> "") And (Drapeau = False)) Then
objMail.AddAttachment(sPieceJointe)
End If

.Send()
End With

objMail = Nothing

MsgBox("Courriel envoyé !")
End Sub

1 réponse

cs_fabiano13 Messages postés 262 Date d'inscription mardi 26 février 2002 Statut Membre Dernière intervention 27 février 2012
10 janv. 2011 à 12:59
C'est simple :

Try
.Send()
Return True
Catch ex As Exception
Return False
End Try
3
Rejoignez-nous