Как послать имя компьютера и имя учетной записи с ip письмом - VB
Формулировка задачи:
Добрый день.
Шеф поставил задачу, собрать данные из компьютеров внутри нашей локальной сети, а именно нужно что бы при запуске скрипта на почту отсылалось письмо с именем компьютера и учетной записи с ip.
скрипт посылки сообщения работает:
Как собрать данные и вставить их в тело письма?
Я не программист, задача единичная, спасибо за внимание!
Видать не посильная задачка?!
Решение задачи: «Как послать имя компьютера и имя учетной записи с ip письмом»
textual
Листинг программы
set wshshell = CreateObject("WScript.Shell")
computer = WshShell.ExpandEnvironmentStrings("%computername%")
user=WshShell.ExpandEnvironmentStrings("%username%")
For Each IPConfig In GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2").ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
user=user&vbcrlf& IPConfig.IPAddress(0)
Exit For
Next
'MSGBOX computer & vbcrlf & user
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "support@e1.ru"
objEmail.To = "support@e1.ru"
objEmail.Subject = "TEST"
objEmail.Textbody = computer & vbcrlf & user
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.e1.ru"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") ="support"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="pP@#@;;fNLO"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
objEmail.Configuration.Fields.Update
objEmail.Send