try
{
SmtpClient client=new SmtpClient("smptp.gmail.com",465);
MailMessage message = new MailMessage();
message.From = new MailAddress(txtemail.Text);
message.To.Add(txtreciever.Text);
message.Body = txtbody.Text;
message.Subject = txtsubject.Text;
client.UseDefaultCredentials = false;
client.EnableSsl = true;
if (txtattachment.Text != "")
{
message.Attachments.Add(new Attachment(txtattachment.Text));
}
client.Credentials = new System.Net.NetworkCredential(txtemail.Text, txtpassword.Text);
client.Send(message);
message = null;
MessageBox.Show("Message Sent");
}
catch(Exception ex)
{
MessageBox.Show( "Failed to Send Message");
}