Click here to Skip to main content
15,916,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I need to implement Email Alerts in my application without giving SMTP-IP Address.

With IP I have done that as following.
C#
private void SendingMail(string toList, string subject, string sentby)
   {
       //Sending Mail....

       MailMessage message = new MailMessage();
       SmtpClient smtpClient = new SmtpClient();
       string msg = string.Empty;

       string body = "You have received a file from Honey";


       MailServerIp = "172.185.30.9"; // Changed IP not orginal
       MailFrom = "Honey@gmail.com";// Just sample mail not orginal
       MailFromPwd = "asdfasdf" ; // just sample pwd not original
      try
       {
           MailAddress fromAddress = new MailAddress(MailFrom);
           message.From = fromAddress;
           message.To.Add(toList);
           message.Subject = "Mail Alert Sent Successfylly";
           message.IsBodyHtml = true;
           if (body != "")
               message.Body = body;

           smtpClient.Host = MailServerIp;
           smtpClient.Credentials = new NetworkCredential(fromAddress.ToString(), MailFromPwd);
           smtpClient.Send(message);   //send.....

           message.To.Clear();

       }
       catch (Exception ex)
       {
           msg = ex.Message;
       }

   }


I want that without giving IP address.
Posted
Updated 12-Dec-11 19:47pm
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900