Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to sent email to gmail.com and yahoo.com


and any other


pls help me any other





C#
public void SenEmail(string EmailAddress)
   {
       if (EmailAddress != "")
       {
           try
           {
               url = "http://www.mednob.com/new/unsubscirbe.aspx?email_id=" + EmailAddress;

               // Mail Using Domain
               MailMessage mM = new MailMessage();
               //mM.From = new MailAddress("tradelink@mednob.in", "Mednob");

               mM.From = new MailAddress("kumar@availtechnologies.net", "Mednob");

               //mM.From = new MailAddress("info@mednob.com", "Mednob");
               mM.To.Add(new MailAddress(EmailAddress));

               mM.Subject = txtSubject.Text;

               mM.Body = ConvertToHtmlFile(filename, url);


               mM.IsBodyHtml = true;


               mM.IsBodyHtml = true;
               mM.Priority = MailPriority.High;
               SmtpClient sC = new SmtpClient("webmail.markersspot.com");


               sC.Port = 25;
               // sC.Credentials = new System.Net.NetworkCredential("mail@availtechnologies.net", "Avail12345");

               sC.Credentials = new System.Net.NetworkCredential("kumar@availtechnologies.net", "seetha07");
               //sC.EnableSsl = true;

               sC.Send(mM);

           }

           catch (Exception ex)
           {

               if (con.State == ConnectionState.Closed)
               {
                   con.Open();
               }

               SqlCommand cmd1 = new SqlCommand("update  tbl_sendmail set status=0 where recipient='" + EmailAddress + "'", con);
               int a = cmd1.ExecuteNonQuery();
               if (con.State == ConnectionState.Open)
               {
                   con.Close();
               }

               wrongmail++;
               //  Response.Write(ex.ToString());
           }
       }


   }


What I have tried:

i search to the google could not get in answer
Posted
Comments
Anisuzzaman Sumon 24-Jun-16 1:56am    
where the exception occurred?Exactly explain your problem.
MohamedEliyas 24-Jun-16 3:43am    
i wont sent to the mail in gmail.com yahoo.com

my error:


{System.Net.Mail.SmtpException: Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.
at System.Net.Mail.RecipientCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at new_Sendmail.SenEmail(String EmailAddress) in f:\MEDNOB\new\sendmail.aspx.cs:line 168}

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