Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Newbie trying something in VBS

Newbie trying something in VBS

Newbie trying something in VBS

deal all,

on my work we have to get some html pages from clients to register their machines for warranty.
i was browsing google and already got pretty far, having a vbs that did what we needed.

now the only thing is, we need a certain html that is on a linux server, but the internal ipadress is different for every linux machine.
so i would like to put up a window, that asks the cutomer to input his internal IP (ie 192.168.1.whatever) and then it should download the html in question and send it to us by mail.

i got it to work using not the ip but the network name, problem here is that not every linux box has the same name...

i'll post my findings here, hope you can help!

' Set your settings
strFileURL = ""
strHDLocation = "c:\the_actual_file.htm"

' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")

objXMLHTTP.open "GET", strFileURL, false

If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Type = 1 'adTypeBinary

objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start

Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing

objADOStream.SaveToFile strHDLocation
Set objADOStream = Nothing
End if

Set objXMLHTTP = Nothing

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "client@mail.com"
objEmail.To = "my@mail.com"
objEmail.Subject = "email subject"
objEmail.Textbody = "some text"
objEmail.AddAttachment "C:\the_actual_file.htm" 'NOTE: DO NOT USE AN "=" SIGN AFTER "AddAttachment"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sen...") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smt...") = _
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smt...") = 25

my script is working, but the only variable is the IP adress wich should be entered by the customer.
another nice thing i would love to add is, that the customer would be able to also add his name into the mail that sends the html file

i hope you people can help out this noob smile

RE: Newbie trying something in VBS

Sounds like you just need to use Inputbox. Such as:

CODE -->

strIP = InputBox("Enter the IP of the server:")

If Len(strIP) > 0 Then
    strFileURL = "http://" & strIP & "/subfolder1/subfolder2/the_act..."
    MsgBox "You didn't enter an IP"
    'Exit here, or do some other error checking
End If 

RE: Newbie trying something in VBS

looks like something I needed smile

tnx! going to try this one out!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close