Visualizzazione dei risultati da 1 a 7 su 7

Discussione: [VB6] Mail script

  1. #1

    [VB6] Mail script

    Salve,
    Ho uno script in vbs che controlla se in 2 file ci sono stringhe differenti.
    Ora vorrei inviare il risultato della query via email.
    Questo è lo script che uso per fare il matching dei files.

    codice:
    dim filename1
    dim filename2
    
    filename1="c:\test1.txt"
    filename2="c:\test2.txt"
    
    
    Set oFSO1 = CreateObject("Scripting.FileSystemObject")
    Set oFSO2 = CreateObject("Scripting.FileSystemObject")
    
    Set oTextFile1 = oFSO1.OpenTextFile(filename1, 1 , True)
    Set oTextFile2 = oFSO2.OpenTextFile(filename2, 1 , True)
    
    
    While oTextFile1.AtEndOfStream <> True
    line1 = oTextFile1.ReadLine
    line2 = oTextFile2.ReadLine
    
    if (line1<>line2) then wscript.echo "I file sono diversi" & vbcrlf & line1 & vbcrlf & line2
    wend
    
    'if the second file has more strings i get the notify
    if (oTextFile2.AtEndOfStream <> True) then wscript.echo "Different Files"
    
    
    oTextFile1.close
    oTextFile2.close
    Questo è invece lo script che uso in genere per inviare email:

    codice:
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = "fox80129@xxx.xom"
    objEmail.To = "test@xxx.com"
    objEmail.Subject = "oggetto"
    objEmail.Textbody = "testohardware"
    
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.virgilio.it"
    
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    
    objEmail.Configuration.Fields.Update
    objEmail.Send
    
    
    wscript.echo "Response Retrieve Mail sent"
    Vorrei semplicemente permettere allo script di inviare via email il risultato.
    Grazie!
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

  2. #2
    Scusami ma non puoi risolvere così:
    if (line1<>line2) then
    messaggio = "i files sono diversi"
    else
    messaggio = "i file sono uguali"
    end if

    e poi nell'invio mail:
    objEmail.Textbody = messaggio

    Ciao

  3. #3
    Purtroppo non funziona come dici tu...si blocca lo script.
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

  4. #4
    Penso che teoricamente debba essere corretto il mio ragionamento, se non va prova ad eseguire in modalità Debug oppure posta il tipo di errore che viene restituito.

  5. #5
    ok...mi da un errore sulla riga 38 che corrisponde a :

    codice:
    WEND
    L'errore è : Expected statement.
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

  6. #6
    UP
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

  7. #7
    Risolto...l'unico problema è che mi chiede user e password per inviare mail...come posso aggiungere questi campi allo script?

    codice:
    dim filename1
    dim filename2
    
    filename1="c:\sitelist.txt"
    filename2="c:\textstream.txt"
    
    
    Set oFSO1 = CreateObject("Scripting.FileSystemObject")
    Set oFSO2 = CreateObject("Scripting.FileSystemObject")
    
    Set oTextFile1 = oFSO1.OpenTextFile(filename1, 1 , True)
    Set oTextFile2 = oFSO2.OpenTextFile(filename2, 1 , True)
    
    
    While oTextFile1.AtEndOfStream <> True
    line1 = oTextFile1.ReadLine
    line2 = oTextFile2.ReadLine
    
    if (line1<>line2) then 
    Mail = "Different files" & vbcrlf & line1 & vbcrlf & line2
    
    end if
    wend
    
    'if the second file has more strings i get the notify
    if (oTextFile2.AtEndOfStream <> True) then 
    Mail = "Different Files"
    
    
    oTextFile1.close
    oTextFile2.close 
    
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = "fox80129@xxx.com"
    objEmail.To = "fox80129@xxxx.com"
    objEmail.Subject = "oggetto"
    objEmail.Textbody = Mail
    
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.virgilio.it"
    
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    
    objEmail.Configuration.Fields.Update
    objEmail.Send
    
    
    wscript.echo "Response Retrieve Mail sent"
    End If
    Dade2 • Premium Windows Hosting • Microsoft Partner
    Server Dedicati • R1Soft daily backups • Dedicated Account Managers

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.