Generally if you write the code for sendmail in using gmail account. It may not work on online. That time you have to Unlocking Google’s Gmail account.

Mail Coding:

//-------------------------Start Code----------------------------------------
public bool sendMail(string eidTo, string msgsub, string msgbody) {

	MailMessage greetings = new MailMessage();
	SmtpClient smtp = new SmtpClient();
	try {
		greetings.From = new MailAddress("", "demo");
		greetings.IsBodyHtml = true;
		greetings.Priority = MailPriority.High;
		greetings.Body = msgbody;
		greetings.Subject = msgsub;
		smtp.Host = "";
		smtp.Port = 587;
		smtp.EnableSsl = true;
		smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
		smtp.UseDefaultCredentials = false;
		smtp.Credentials = new System.Net.NetworkCredential("", "xyzpassword");
		return true;
	catch (Exception) { throw; }

//-------------------------End code------------------------------

Google may prevent an application from accessing your account
Here you can enable applications to access google account with your credentials:
(Login gmail account & click the above link)
Set UseDefaultCredentials to false, since you define credentials for the connection.

Set this property to true when this SmtpClient object should, if requested by the server, authenticate using the default credentials of the currently logged on user.

If the UseDefaultCredentials property is set to false, then the value set in the Credentials property will be used for the credentials when connecting to the server.
Happy coding………………….