Bonjour à tous.
Dans une application, nous utilisons SMTP pour envoyer des mail dynamiquement.
Voici le code utilisé :
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
 
var objEmail = new ActiveXObject("CDO.Message");  
objEmail.From =  WUser;
objEmail.To = WDestinataire; 
objEmail.Cc = WDestinataire2; 
objEmail.Subject = WObjet; // "HELLO WORLD";  
objEmail.Textbody = WCorps;
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2;  
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = WSmtp;
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = WUser;
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = WMdp;
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = WPort;  
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = false;
objEmail.Configuration.Fields.Update(); 
objEmail.Send();
Ce code fonctionne très bien
MAIS...
Je cherche à tester un retour sur le SEND afin de pouvoir vérifier si le mail a bien été envoyé ou pas.
J'ai bien essayé le Try / Catch comme ci-dessous, mais ça ne fonctionne pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
try 
{ 
errMail = objEmail.Send();
alert("Pas d'erreur = " + err);
}
catch (err) 
{
alert("Erreur N° = " + err);
};
Merci d'avance pour votre aide.