• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

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


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 = "mail.servername.com"  it only works if I put the IP address.  Is there a way to get IP address from the mail server name?
0
Jenny12345
Asked:
Jenny12345
1 Solution
 
wishguitarCommented:
IPHostEntry hostEntry = Dns.GetHostByName("mail.comcast.net");
if (hostEntry != null)
{
      foreach (IPAddress address in hostEntry.AddressList)
            Console.WriteLine(address.ToString());
}
0
 
Jenny12345Author Commented:
yes this works great  - thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now