Visual Basic code to find SMTP Address

JD2369

Member
Joined
Jan 12, 2011
Messages
19
Programming Experience
Beginner
Is there a way i can write this into a command button?

In a CMD Prompt if you type:

nslookup
set type=mx
set timeout=30
emailaddressdomain.com

it will give you the outgoing mail server address

is there a way i can write that into a command button and display the results into a textbox?

Thank you
 
VB.NET:
Dim info As New ProcessStartInfo("nslookup", "-type=mx -timeout=30 sendmail.org")
With info
    .RedirectStandardOutput = True
    .UseShellExecute = False
    .CreateNoWindow = True
End With
Dim proc As Process = Process.Start(info)
Me.ResultTextBox.Text = proc.StandardOutput.ReadToEnd
proc.Dispose()
 
textbox1 will ask.....DomainNameEmail

buttono1 will do the search and textbo2 will show the results

how can i change your code for this setup?
 
Here's an example on how to add two strings together, where one of the operands is the Text property value from a TextBox control:
VB.NET:
Dim arg As String = "-type=mx -timeout=30 " & Me.Address.Text
Now you can use this variable in the ProcessStartInfo constructor call instead of the literal String value.

I explained about using a button in your other thread.
 
Dim arg As String = "-type=mx -timeout=30 " & Me.TextBox3.Text
With info
.RedirectStandardOutput = True
.UseShellExecute = False
.CreateNoWindow = True
End With
Dim proc As Process = Process.Start(info)
Me.TextBox1.Text = proc.StandardOutput.ReadToEnd
proc.Dispose()
End Sub


Name 'info' is not declared
______________________________________________________




If i switch it to

Dim arg As String = "-type=mx -timeout=30 " & Me.TextBox3.Text
With arg
.RedirectStandardOutput = True
.UseShellExecute = False
.CreateNoWindow = True
End With
Dim proc As Process = Process.Start(arg)
Me.TextBox1.Text = proc.StandardOutput.ReadToEnd
proc.Dispose()
End Sub


RedirectStandardOutput is not a member of string
Useshellexecute is not a member of string
UseShellExecute is not a member of string
CreateNoWindow is not a member of string



Please Help...Thanks
 
VB.NET:
Dim info As New ProcessStartInfo("nslookup", "-type=mx -timeout=30 " & Me.Textbox3.Text & ")
With info
    .RedirectStandardOutput = True
    .UseShellExecute = False
    .CreateNoWindow = True
End With
Dim proc As Process = Process.Start(info)
Me.TextBox1.Text = proc.StandardOutput.ReadToEnd
proc.Dispose()

P.S. Give your controls meaningful names. It will make it easier to code.
 
Back
Top