Thanks for the reply.
I changed my code to this:
protected void btnSend_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add("lingo1357@gmail.com");
mailMessage.From = new MailAddress(txtEmail.Text, txtName.Text);
mailMessage.Subject = txtSubject.Text;
mailMessage.Body = txtMessage.Text;
mailMessage.IsBodyHtml = false;
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 465);
smtpClient.Credentials = new System.Net.NetworkCredential("ling1357@gmail.com", "lingo13410");
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
lblEmailResult.Text = "ایمیل با موفقیت ارسال شد";
}
catch (Exception ex)
{
lblEmailResult.Text = "خطا در ارسال ایمیل ، لطفا مجددا تلاش نمایید " + ex.Message;
}
}
}
also I used these articles:
http://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm
https://www.digitalocean.com/community/tutorials/how-to-use-google-s-smtp-server
but still keep this error: the operation has timed out.
you can try it your self, the page is: http://sedayetasvir.ir/Email.aspx
The first textbox is for name.
The second textbox is for subject.
The third textbox is for email and the forth textbox is for message.
Also the left button is for sending and the right button is for cleaning.
Let me know your opinion and what is wrong with my code.
Thanks