arash_flag
شنبه 20 تیر 1394, 15:05 عصر
سلام دوستان من این کد ها رو برای ارسال ایمیل جمع آوری کردم اما خطا میده مشکل کجاست؟
SmtpClient smtp = new SmtpClient();
MailMessage email = new MailMessage();
email.From = new MailAddress(txt_email.Text, txt_name.Text);
email.To.Add("my email");
email.Subject = txt_subject.Text;
email.SubjectEncoding = Encoding.UTF8;
email.Body = txt_text.Text;
email.BodyEncoding = Encoding.UTF8;
smtp.Host = "mail.google.com";
smtp.UseDefaultCredentials = false;
NetworkCredential nc = new NetworkCredential();
nc.UserName = "MY email";
nc.Password = "password";
smtp.Credentials = nc;
smtp.Send(email);
lblmsg.Text = "پیام با موفقیت ارسال شد";
اگر کد بهتری دارین ک برای جیمیل و یاهو جواب میده لطفا بگذارید
SmtpClient smtp = new SmtpClient();
MailMessage email = new MailMessage();
email.From = new MailAddress(txt_email.Text, txt_name.Text);
email.To.Add("my email");
email.Subject = txt_subject.Text;
email.SubjectEncoding = Encoding.UTF8;
email.Body = txt_text.Text;
email.BodyEncoding = Encoding.UTF8;
smtp.Host = "mail.google.com";
smtp.UseDefaultCredentials = false;
NetworkCredential nc = new NetworkCredential();
nc.UserName = "MY email";
nc.Password = "password";
smtp.Credentials = nc;
smtp.Send(email);
lblmsg.Text = "پیام با موفقیت ارسال شد";
اگر کد بهتری دارین ک برای جیمیل و یاهو جواب میده لطفا بگذارید