Ir para conteúdo
Fórum Script Brasil

flavio.11d

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Tudo que flavio.11d postou

  1. Senhores(as), Preciso de uma vbs que faça a leitura do conteúdo de um arquivo *.log colocando no corpo de um email, em seguida faça o envio. Não sou expert em vbs, mas consegui desenvolver duas, a primeira faz a leitura do conteúdo de um arquivo .log mostrando em uma janela, e a segunda zipa o arquivo.log e faz o envio por e-mail. Qualquer ajuda é bem vinda. VBS 1 { REM – I create FSO object. Set FSO = WScript.CreateObject("Scripting.FileSystemObject") REM – I Create OTF object . REM – It will containall lines of the C:\FileName.Txt file. Set OTF = FSO.OpenTextFile("C:\script\lab\arquivo.log", 1, True, 0) REM –I run the loop on the OTF object to read all lines of the file. Do While OTF.AtEndOfStream = False REM – The OTF.ReadLine statement reads the current REM – line and move the cursor to the next line. Current_Line= OTF.ReadLine REM – Show the current line. MsgBox (Current_Line) Loop REM – I close the objects Set OTF = Nothing Set FSO = Nothing } VBS 2 { Dim fso, arq Set fso = CreateObject("Scripting.FileSystemObject") For Each objFiles In fso.GetFolder("C:\script\lab\").Files If InStr(objFiles.Name, "arquivo02.log") Then arq = Split(objFiles.Name, ".") fso.MoveFile "C:\script\lab\" & objFiles.Name , "C:\script\lab\TX\" & objFiles.Name End if next caminho = "C:\script\lab\TX\" If fso.GetFolder(caminho).Files.Count > 0 Then Email End If Function Email() Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run (Chr(34) + "C:\Arquivos de programas\7-Zip\7z.exe" + Chr(34) + " a -mx9 -t7z " + Chr(34) + "C:\script\lab\TX\arquivo02.7z" + Chr(34) + " " + Chr(34) + "C:\restless\log\" + Chr(34)) Set objEmail = CreateObject("CDO.Message") objEmail.From = "remetende@email.com.br" objEmail.Subject = "Assunto" objEmail.To = " destino@email.com.br " objEmail.Textbody = "Corpo do email 1 " & chr(13) & "Corpo do email 2" objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ "192.168.63.4" objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 objEmail.Configuration.Fields.Update objEmail.Configuration.Fields.Update objEmail.AddAttachment "C:\script\lab\TX\arquivo02.7z" objEmail.Send msgbox("A função foi chamada") End Function }
×
×
  • Criar Novo...