I am using following code to send email.when i am tring to send mail i am getting the error message
MailMessage mail = new MailMessage(from.txt, to.txt, subject, body);
SmtpClient clint = new SmtpClient();
//for determile email smtp...
string x = from.txt;
int startIndex = x.IndexOf('@');
int endIndex = x.LastIndexOf('.');
int length = endIndex - startIndex;
string xx = x.Substring(startIndex + 1, length - 1);
if (xx == "gmail" || xx == "Gmail")
{
clint.Host = "smtp.gmail.com";
clint.Port = 587;
clint.EnableSsl = true;
}
if (xx == "Hotmail" || xx == "hotmail" || xx == "live" || xx == "Live")
{
clint.Host = "smtp.live.com";
clint.Port = 587;
clint.EnableSsl = true;
}
if (xx == "yahoo" || xx == "Yahoo")
{
clint.Host = "smtp.mail.yahoo.com";
clint.Port = 465;
clint.EnableSsl = true;
}
clint.Credentials = new System.Net.NetworkCredential(username, password);
clint.DeliveryMethod = SmtpDeliveryMethod.Network;
clint.UseDefaultCredentials = false;
clint.Send(mail);
MetroMessageBox.Show(this, "Email Successfully Send", "Success",
MessageBoxButtons.OK, MessageBoxIcon.Information);
and also how can attach any file to this email