vbs:alertmailer
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
vbs:alertmailer [2013/06/04 15:50] – gfsadministrator | vbs:alertmailer [2014/04/07 19:55] (current) – old revision restored (2014/04/07 19:51) gfsadministrator | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Mailer ====== | ||
+ | Lo script può essere utilizzato per mandare mail verso l' | ||
+ | |||
+ | Questo è un esempio di file batch in grado di richiamare e utilizzare lo script: | ||
+ | |||
+ | <file winbatch Alert.cmd> | ||
+ | set sender=" | ||
+ | set alert=giovanni@bianchi.it | ||
+ | set message=Messaggio di prova! | ||
+ | cscript Mailer.vbs %sender% %alert% " | ||
+ | </ | ||
+ | |||
+ | Dove " | ||
+ | |||
+ | Qui di seguito il VBS: | ||
+ | |||
+ | <file vb Mailer.vbs> | ||
+ | ' MAILER | ||
+ | ' Ultima modifica 04062013-rev0 dev@gfsolone.com | ||
+ | ' Vedi: http:// | ||
+ | |||
+ | Set WshNetwork = WScript.CreateObject(" | ||
+ | Set objNTInfo = CreateObject(" | ||
+ | Set objFSO = CreateObject(" | ||
+ | |||
+ | dim strFrom, strAlert, strSubject, strTextBody | ||
+ | Set objArgs = WScript.Arguments | ||
+ | strFrom = objArgs(0) | ||
+ | strAlert = objArgs(1) | ||
+ | strSubject = objArgs(2) | ||
+ | strTextBody = objArgs(3) | ||
+ | |||
+ | ' Rilevamento IP locale / VPN della macchina | ||
+ | ' Vedi wiki: http:// | ||
+ | dim NIC1, Nic, StrIP, CompName | ||
+ | Set NIC1 = GetObject(" | ||
+ | For Each Nic in NIC1 | ||
+ | if Nic.IPEnabled then | ||
+ | StrIP = Nic.IPAddress(i) | ||
+ | CompName = WshNetwork.Computername | ||
+ | Dim WMI, Configs, Config, Adapters, Adapter | ||
+ | Set WMI = GetObject(" | ||
+ | Set Configs = WMI.ExecQuery(" | ||
+ | For Each Config In Configs | ||
+ | Set Adapters = WMI.AssociatorsOf(" | ||
+ | For Each Adapter In Adapters | ||
+ | VPNIP = Config.IPAddress(0) | ||
+ | Next | ||
+ | Next | ||
+ | ' | ||
+ | ' | ||
+ | '& | ||
+ | '& | ||
+ | ' | ||
+ | end if | ||
+ | next | ||
+ | |||
+ | ' SendMail GSolone 20121122 rev2 con SMTP Esterno | ||
+ | ' Vedi wiki: http:// | ||
+ | ' La modifica allo script permette l' | ||
+ | |||
+ | ' | ||
+ | Set objMessage = CreateObject(" | ||
+ | 'debug objMessage.From = " | ||
+ | 'debug objMessage.To = " | ||
+ | 'debug MsgBox "From rilevato: " & strFrom & vbNewLine & "To rilevato: "& strAlert & vbNewLine | ||
+ | objMessage.From = strFrom | ||
+ | objMessage.To = strAlert | ||
+ | objMessage.Subject = strSubject | ||
+ | objMessage.TextBody = strTextBody & vbCRLF & vbCRLF & " | ||
+ | objMessage.Configuration.Fields.Item (" | ||
+ | objMessage.Configuration.Fields.Item (" | ||
+ | objMessage.Configuration.Fields.Item (" | ||
+ | objMessage.Configuration.Fields.Item (" | ||
+ | objMessage.Configuration.Fields.Item (" | ||
+ | objMessage.Configuration.Fields.Item (" | ||
+ | objMessage.Configuration.Fields.Item (" | ||
+ | objMessage.Configuration.Fields.Update | ||
+ | objMessage.Send | ||
+ | </ | ||
+ | |||
+ | strFrom = objArgs(0), strAlert = objArgs(1), strSubject = objArgs(2), strTextBody = objArgs(3) vengono ereditati dal file batch (possono quindi essere modificati direttamente nel VBS se preferite non inserirli nel batch perdendo però la comodità di richiamare un solo VBS da più script di terze parti). Vanno verificate inoltre le impostazioni nella parte relativa al " |
vbs/alertmailer.txt · Last modified: 2014/04/07 19:55 by gfsadministrator