frobinson70
MIS
I am a noob in VB and am trying to write a Windows Form Application. My problem is I am trying to make it when you click the email button, it will open an Outlook email, include all of the required information etc. My problem is that when you click the button, it generates (2) email messages. I cannot figure it out!
Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim myHost As String = System.Net.Dns.GetHostName
Dim myIPs As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(myHost)
Dim osVersion = My.Computer.Info.OSVersion
Dim osPlatform = My.Computer.Info.OSFullName
Dim totalPhysicalMemmory = My.Computer.Info.TotalPhysicalMemory
Dim drive = My.Computer.FileSystem.GetDriveInfo("C:\")
Dim space = drive.AvailableFreeSpace
Dim space2 = drive.TotalSize
Dim height = My.Computer.Screen.Bounds.Height
Dim width = My.Computer.Screen.Bounds.Width
Dim objWMIService, colInstalledPrinters
Dim megabytes As String
Dim memorybytes As String
Dim megabytes2 As String
Dim MBytes As Double
Dim MBytes2 As Double
Dim MMBytes As Double
Dim objPrinter
objPrinter = Nothing
objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & myHost & "\root\cimv2")
colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer where Default = 'True'")
For Each objPrinter In colInstalledPrinters
Next
Dim strComputer
Dim colSettings
strComputer = "."
objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
colSettings = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem In colSettings
Next
'******************************************************************
MBytes = (space \ 1024) \ 1024 \ 1024
MBytes2 = (space2 \ 1024) \ 1024 \ 1024
megabytes = Format(MBytes, "###.###") & " GB"
megabytes2 = Format(MBytes2, "###.###") & " GB"
MMBytes = (totalPhysicalMemmory \ 1024) \ 1024 \ 1024
memorybytes = Format(MMBytes, "###.###") & " GB"
'******************************************************************
For Each myIP As System.Net.IPAddress In myIPs.AddressList
'******************************************************************
colSettings = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer In colSettings
Dim colItems
objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem In colItems
Dim officepath, fso, returnstring
officepath = "C:\Program Files (x86)\Imprivata\OneSign Agent\"
fso = CreateObject("scripting.filesystemobject")
returnstring = fso.getfileversion(officepath & "ISXAgent.exe")
Dim citrixPath, returnVersion
citrixPath = "C:\Program Files (x86)\Citrix\ICA Client\"
fso = CreateObject("scripting.filesystemobject")
returnVersion = fso.getfileversion(citrixPath & "wfica32.exe")
Dim IEPath, IEVersion
IEPath = "C:\Program Files (x86)\Internet Explorer\"
fso = CreateObject("scripting.filesystemobject")
IEVersion = fso.getfileversion(IEPath & "iexplore.exe")
'******************************************************************
Dim objOutlk, objMail, strMsg
Const olMailItem = 0
objOutlk = CreateObject("Outlook.Application")
objMail = objOutlk.createitem(olMailItem)
objMail.To = "xxxx.xxxx@myname.com"
objMail.subject = "Info for:: " & myIPs.HostName & " :: " & CStr(Month(Now)) & "/" & CStr(Year(Now))
strMsg = "Please paste this information into Footprints ticket" & vbCrLf
strMsg = strMsg & ("*************************************************") & vbCrLf
strMsg = strMsg & (objComputer.Manufacturer) & vbCrLf
strMsg = strMsg & (objComputer.Model) & vbCrLf
strMsg = strMsg & ("*************************************************") & vbCrLf
strMsg = strMsg & ("User Name: " & SystemInformation.UserDomainName & "\" & SystemInformation.UserName) & vbCrLf
strMsg = strMsg & ("Your Computer Name: " & myIPs.HostName) & vbCrLf
strMsg = strMsg & ("Your IP Address: " & myIP.ToString) & vbCrLf
strMsg = strMsg & ("Default Printer: " & objPrinter.Name) & vbCrLf
strMsg = strMsg & ("*************************************************") & vbCrLf
strMsg = strMsg & (osPlatform & " v" & osVersion) & vbCrLf
strMsg = strMsg & ("Citrix Version: " & returnVersion) & vbCrLf
strMsg = strMsg & ("Imprivata SSO Version: " & returnstring) & vbCrLf
strMsg = strMsg & ("Internet Explorer Version: " & IEVersion) & vbCrLf
strMsg = strMsg & ("*************************************************") & vbCrLf
strMsg = strMsg & (objItem.Manufacturer & " - " & objItem.Name) & vbCrLf
strMsg = strMsg & ("Memory: " & memorybytes) & vbCrLf
strMsg = strMsg & ("HDD Size: " & megabytes2) & vbCrLf
strMsg = strMsg & ("Available HDD Space: " & megabytes) & vbCrLf
strMsg = strMsg & ("Display: " & width & (" X ") & height) & vbCrLf
objMail.body = strMsg
objMail.display()
'objMail.Send()
'Clean up
objMail = Nothing
objOutlk = Nothing
Next
Next
Next
End Sub