Sunday 21 July 2019

Send email using Godaddy asp.net c# from gmail account

///////////////////////
                         ///////////////////  Godaddy

public static void Email_Send_Godady(string Htmlbody, string mSubject)
{
  try
   {
       string[] Credentials = { "Yourmail@gmail.com", "password" };

       MailMessage msgs = new MailMessage();
       msgs.To.Add("ToEmail id");
       msgs.From = new MailAddress(Credentials[0], "Sender Name"); ;
       msgs.Subject = mSubject;
       msgs.Body = Htmlbody;
       msgs.IsBodyHtml = true;
       SmtpClient client = new SmtpClient();
       client.Credentials = new System.Net.NetworkCredential(Credentials[0], Credentials[1]);
       client.Host = "relay-hosting.secureserver.net";
       client.Port = 25;
       client.EnableSsl = false;
       client.UseDefaultCredentials = false;
       client.Send(msgs);
    }
    catch (Exception ex)
    {
       string msg = ex.ToString();
    }

}


                                    ///////////////////  Gmail


public static void Email_Send_Godady(string Htmlbody, string mSubject)
{
  try
   {
       string[] Credentials = { "Yourmail@gmail.com""password" };

       MailMessage msgs = new MailMessage();
       msgs.To.Add("ToEmail id");
       msgs.From = new MailAddress(Credentials[0], "Sender Name"); ;
       msgs.Subject = mSubject;
       msgs.Body = Htmlbody;
       msgs.IsBodyHtml = true;
       SmtpClient client = new SmtpClient();
       client.Credentials = new System.Net.NetworkCredential(Credentials[0], Credentials[1]);
       client.Host = "smtp.gmail.com";
       client.Port = 587;
       client.EnableSsl = true;
       client.UseDefaultCredentials = false;
       client.Send(msgs);
    }
    catch (Exception ex)
    {
       string msg = ex.ToString();
    }



}

No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...