Bonjour,

je débute en VBS, voilà je souhaite envoyer un mail et surtout vérifié si objMail.Send s'execute bien. Je reçois bien le mail, mon fichié lo est bien généré.
Mais comment vérifier si mon mail est bien envoyé ? avec la gestion d'erreur
si oui/non l'ajouter dans mon fichier log

Merci à tous

Voici mon code:

****************************************************
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Dim Log
Dim Arbo
Dim Rapport
Dim objFSO, FileLog, fso, oShell
Set objFSO = CreateObject("Scripting.FileSystemObject")
MyDate = Day(Now) & "." & Month(Now) & "." & Year(Now)
 
Nom_appli="applis.vbs"
Arbo="C:\path\SendMail\"
Rapport="path\rapport_" & UniqueID & ".html"
Log="C:\path\test_" & MyDate & ".log"
 
Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set FileLog = FSO.CreateTextFile(Log)
 
Sub Msglog(severite,code,label)
	wscript.echo Mydate & "-" & time & " " & severite & " " & code & " " & label
	FileLog.WriteLine(Mydate & "-" & time & " " & severite & " " & code & " " & label) '& vbcrlf
 
End sub
 
Sub Verif (Rapport)
	msglog "0","0000","---Debut: Verification présence du Rapport"
	Set Objectfso =CreateObject("Scripting.FileSystemObject")
	If (objFSO.FileExists(Rapport)) Then
		msglog "0","0000","---Rapport présent"
	Else
		Msglog "1","0001","---WARNING: Rapport non présent"
		wscript.quit ()		
		End If
		msglog "0","0000","---Fin: Verification présence du Rapport"
End Sub
 
Sub Envoi	
	msglog "0","0000","---Debut: Envoi du Rapport "
	Set objMail = CreateObject("CDO.Message") 
	Set oFSO = CreateObject("Scripting.FileSystemObject")
 
	With objMail
	.Subject  = "[sujet] : Rapport de test"
	.From     = "user test"
	.To       = ReadAllListUsers
	.TextBody = "Bonjour," & VbNewLine & VbNewLine & _
		"Veuillez trouver ci-joint, le document:" & VbNewLine & VbNewLine & _
		"Cordialement," & VbNewLine & _
		"Exploitation serveur." & VbNewLine & VbNewLine
	.AddAttachment("D:\path\test_" & UniqueID & ".html")
End With
 
With objMail.Configuration.Fields
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")       = "mailhost.der.test.fr"
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")   = 25
	.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")        = 2 'CDO.cdoSendUsingPort
	.Update
End With
 
objMail.Send
	msglog "0","0000","---Fin: Envoi du Mail "
 
End Sub
 
set s = createobject("WScript.Shell")
s.currentdirectory = Arbo
set s = nothing 
'---------------------------
' Corps su script
'---------------------------
msglog "0","0000","---Debut: " & Nom_appli
Verif (Rapport)
Envoi
msglog "0","0000","---Fin: " & Nom_appli
FileLog.Close