[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

strComputer and CDO/HTML

Asked by Simon336697 in Visual Basic Programming, VB Script

Tags: from, win32_process

Hi guys hope you can help!!

Okay, I have the following code that is just about 100% working, but Id like you nice people to examine it (see if there is anything that really isnt being done as per standard good programming practice etc).

What it does is the following:

Queries the local machine Win32_Process, returns results, pumps the results into a variable within an email message.

So the output is something like the following:
===================================================== Email Message
List of Running Processes On System:  DELL101

                              Name               ProcessID
                              System Idle      Process 0
                               System              4
                              etc etc

The problem Im having is the following:

The only way I can the computer name to appear is if I hard code the computer name into my script.
I want to use strComputer = "." but this just returns a dot, not the computer name. So Im not sure where to place it in my script so I dont have to hard code the name.

'==========================================TITLE OF EMBEDDED HTML (code snippet)

strComputer = "DELL101"
strHTML = strHTML & "<HTML>"

Guys can someone advise me on where Im going wrong in my code so that I dont have to hard code the computer name?
Thanks for any help

================================================ HERE IS MY CODE:

Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Dim strComputer
Const cdoSendUsingPort = 2
Const cdoBasic = 1 'basic (clear-text) authentication
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

With Flds
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpServer"
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "emailaddress"
    .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Update
End With

'================================================================TITLE OF EMBEDDED HTML

strComputer = "DELL101"
strHTML = strHTML & "<HTML>"
strHTML = strHTML & "<BODY bgcolor='green'>"
'strComputer = "."
strHTML = strHTML & "List of "
strHTML = "<b>" & "<i>" & strHTML & "Running Processes On System: " & strComputer & "</i>" & "</b>"

strHTML = strHTML & "<p>" & "</p>"
strHTML = strHTML & "<br>" & "<br>"

'===============================================================TABLE FOLLOWS

Set objWMIService = GetObject("winmgmts:" & "\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_Process")
strHTML = strHTML &  "<table border='1' style='border-collapse: collapse' align='center' bordercolor='purple' bgcolor='pink' width='35%' id='Table1'>"

'===============================================================TABLE HEADER ROW
strHTML = strHTML & "<tr bgcolor='#FFFF00'>"
strHTML = strHTML & "<td width='70%'>" & "<b>" & "Name" & "</b>" & "</td>"
strHTML = strHTML & "<td width='30%'>" & "<b>" & "ProcessID" & "</b>" & "</td>" & "</b>"
strHTML = strHTML & "</tr>"

'=======================================================================THE ROWS......
For Each objItem in colItems

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td width='70%'>" & objItem.Name & "</td>"
strHTML = strHTML & "<td width='30%'>" & objItem.ProcessID & "</td>"
strHTML = strHTML & "</tr>"
Next
strHTML = strHTML & "</table>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"

'==Apply the settings to the message:
With iMsg
    Set .Configuration = iConf
    .To = "emailaddress"
    .From = """Mr Wiggles"" <emailaddress>"
    .Subject = "This is a test CDOSYS message (Sent via Port 25)"
    .HTMLBody = strHTML
    .Send
End With


' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

MsgBox "Mail Sent!"

'======================================================CODE END
[+][-]02/18/07 02:23 PM, ID: 18560002Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/18/07 02:23 PM, ID: 18560004Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/18/07 02:25 PM, ID: 18560012Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/18/07 02:28 PM, ID: 18560023Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/18/07 02:40 PM, ID: 18560056Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02/18/07 02:54 PM, ID: 18560106Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/18/07 03:03 PM, ID: 18560129Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/19/07 12:04 PM, ID: 18565540Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Visual Basic Programming, VB Script
Tags: from, win32_process
Sign Up Now!
Solution Provided By: sirbounty
Participating Experts: 3
Solution Grade: A
 
[+][-]02/19/07 11:07 PM, ID: 18568826Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89