' SENDMAIL (BODY TEXT FROM A TXT FILE) GSolone 20130315 rev0 ' Based on SendMail GSolone 20121122 rev0 ' Utilizzo: set delle variabili da script command per: ' %sender% -mittente ' %alert% -destinatario o destinatari ' %COMPUTERNAME% -hostname della macchina da variabile d'ambiente (vale via DOS, non VBS) ' ' Esecuzione del sendmail da script: cscript sendmail.vbs //B %Sender% %alert% "OCS agent problem on %COMPUTERNAME% (domain.tld)" Set objNTInfo = CreateObject("WinNTSystemInfo") Set objMessage = CreateObject("CDO.Message") Set objFSO = CreateObject("scripting.filesystemobject") Set objArgs = WScript.Arguments 'Leggo dalla %UserProfile%\Desktop il file generato dal batch Dim objShell : Set objShell = CreateObject("WScript.Shell") Dim USER_PROFILE : USER_PROFILE = objShell.ExpandEnvironmentStrings("%UserProfile%") Set objFile = objFSO.OpenTextFile(USER_PROFILE & "\Desktop\Informazioni_Sistema.txt", 1, False, 0) strFile = objFile.ReadAll objMessage.From = objArgs(0) objMessage.To = objArgs(1) objMessage.Subject = objArgs(2) objMessage.TextBody = strFile objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.domain.local" objMessage.Configuration.Fields.Update objMessage.Send