How about you try this.....
first check connection...
public bool Checking_Internet_Connection()
{
try
{
System.Net.Sockets.TcpClient clnt = new System.Net.Sockets.TcpClient("www.google.com", 80);
clnt.Close();
return true;
}
then send message to required email address....
public void Send_Email(Email_Message_Details Email_msg_details)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("gmailaccount");
mail.To.Add("email address you want to send");
mail.Subject = Email_msg_details.SUBJECT;
mail.Body = Email_msg_details.BODYMESSAGE;
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("gmailaccount", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
}
catch
{
return;
}
}