Bonjour,

J'ai une base de donnée contrats.mdb avec des contrats. Je voudrais faire un script .vbs qui renvois les informations des contrats (libellé + société) dans la table liste, et qui ensuite envois un mail a un utilisateur.
Le but est d'éviter à l'utilisateur de lancer access et d'exécuter la requête.

je suis bloqué pour récupéré les informations libellé + société et les mettre dans le 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
Set conn = CreateObject("ADODB.Connection")
' Connect to the database
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\contrats.mdb"
conn.Open strConnect
Set RS=CreateObject("ADODB.Recordset")
SQL="select liste.société, liste.libellé from liste where DateDiff('D', [date_fin], Date())" 
Dim Nom
Dim rapport
set rapport = fso.CreateTextFile(filetext + ".txt")
Set fso = CreateObject
Filetext=Inputbox
Nom=prestataire
If D < 110 then
Dim MAIL, CON
 
    Set MAIL = CreateObject("CDO.Message")
    Set CON = CreateObject("CDO.Configuration")
        'use the address of your outbound smtp server, i.e. mail.yahoo.com or smtp.google.com, etc.
    CON.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "192.168.7.1"
    CON.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    CON.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    'CON.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "toto"
    'CON.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "windows2003"
    CON.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
    CON.Fields.Update
    Set MAIL.Configuration = CON
    MAIL.From = "tata@totosarl.com"
    MAIL.To = "titi@totosarl.com"
    'MAIL.CC = ""
    MAIL.Subject = "Contrat arrive à échéance dans trois mois"
    'MAIL.AddAttachment "d:\test.txt"  (je pensais mettre le résultat dans un .txt qui serait en pièce jointe)
    MAIL.TextBody = Nom
    MAIL.HTMLBody = "<p>Liste des contrats qui expire dans 3 mois</p>"
    MAIL.Send
'    Set MAIL = Nothing
'    Set CON = Nothing
Ca fait depuis ce matin que j'essaye des trucs, mais aucun ne fonctionne.

merci d'avance de votre aide.