C# Is there a way to get IP address from the mail server name?

Posted on 2005-04-14
Last Modified: 2011-09-20

I have a C# windows forms app in the email function I am using the smtpmail object to send the mail.  However, it does not work when I set the stmpmail.servername = ""  it only works if I put the IP address.  Is there a way to get IP address from the mail server name?
Question by:Jenny12345
    LVL 3

    Accepted Solution

    IPHostEntry hostEntry = Dns.GetHostByName("");
    if (hostEntry != null)
          foreach (IPAddress address in hostEntry.AddressList)

    Author Comment

    yes this works great  - thank you

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now