I'm building a web page with visual studio 2010. I want to used pass word recovery control. I need to find out what server Name is, so I can use SMTP setting to send emails to the user who forgets his pass word. I don't know how to get it. Does anybody know. I appreciate it very much.
Asked
Active
Viewed 54 times
-1
-
When you send e-mails locally, is easiest to use the `localhost` as the "server name". – Aristos Aug 22 '14 at 19:43
1 Answers
1
My.Computer.Name
should do the trick in VB. @Vache said that My.Computer
does not exist in C#.
Or
System.Environment.MachineName
, as pointed out by a commentor.
It looks like System.Environment.MachineName
may be preferred, as that is a static method. My.Computer.Name
seems to be added at the project level; when I just tried it in the Immediate Window within a solution that has numerous projects, the call was ambiguous. I had to fully qualify it by a project's namespace before I could get the value. E.g., MyNamespace.Project1.My.Computer.Name
. However, you shouldn't have to qualify it if you call it from within a project instead of a global area like I did.

ps2goat
- 8,067
- 1
- 35
- 68