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 73 74 75 76 77 78 79 80 81 82
| Const ctePourLecture = 1
Const ctePourEcrire = 2
Const ctePourAjouter = 8
Dim objFSO, objDossier, objFichier, objResultat
Dim Repertoire, NomFichierTxt, Rep, liste_fichier
On Error Resume Next
Rep = "D:\Appli\Import\Centre\Importes"
NomFichierTxt = "Resultat_Fichiers_reçus.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDossier = objFSO.GetFolder(Rep)
Set objResultat = objFSO.CreateTextFile("D:\Appli\Import\Centre\Importes\Resultat_Fichiers_reçus.txt",ctePourEcrire)
If (objDossier.Files.Count > 0) Then
For Each objFichier In objDossier.Files
If (InStr(1, objFichier.Name, ".xml", 1) > 0) Then
objResultat.WriteLine objFichier.Name
liste_fichier=liste_fichier + objFichier.Name & VbNewLine
End If
Next
End If
objResultat.Close
Set objResultat = Nothing
Set objDossier = Nothing
Set objFSO = Nothing
Const ForReading = 1, ForWriting = 2
Dim oFso, f
Dim ts, nl
Set oFso = CreateObject("Scripting.FileSystemObject")
Set f = oFso.OpenTextFile("D:\Appli\Import\Corse\Resultat_Fichiers_reçus.txt", ForReading)
ts = f.ReadAll '-- Lit la totalité du fichier
Const DESTINATAIRES="adress destinataire"
Const DESTINATAIRES_CC=""
Const FICHIER_1="D:\Appli\Import\Centre\Importes\Resultat_Fichiers_reçus.txt"
Dim WshNet,objMail,computername
On Error Resume Next
Set WshNet = CreateObject("Wscript.Network" )
Set objMail = CreateObject("CDO.Message")
computername = WshNet.ComputerName '--- Nom du serveur ou est exécuté le script
'-------------------------------------------------------------------------
'---- Envoi du log d'install par mail
'-----------------------------------------------------------------------------
With objMail
.Subject = "[APPLI] : Nombre de fichiers « tests » reçus " & date
.to = DESTINATAIRES
.cc = DESTINATAIRES_CC
.From = "Appli_" & computername & "@.fr"
.TextBody = "Bonjour," & VbNewLine & VbNewLine & _
"A " & Time & " le " & date & ", Appli a reçu " & f.Line & " fichiers. de la part de Paris" & VbNewLine & VbNewLine & _
"Attention, ne pas répondre à ce mail qui est généré automatiquement." & VbNewLine & VbNewLine &_
"" & Liste_Fichier & VbNewLine & VbNewLine &_
"Cordialement." & VbNewLine & VbNewLine
.AddAttachment(FICHIER_1)
End With
With objMail.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailhost.dus.atlas.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
wscript.quit 0 |
Partager