sre.net
جمعه 13 بهمن 1385, 09:51 صبح
سلام ،
من کد زیر را برای ارسال ایمیل در دات نت 2 نوشتم و از کلاس net هم استفاده کردم اما با مشکل زیر برخورد می کنم .
No connection could be made because the target machine actively refused it
کد من به این شکل نوشته شده
MailMessage myMessage = new MailMessage();
SmtpClient myMail = new SmtpClient();
if (Page.IsValid)
{
MailAddress fromAddress = new MailAddress(txtFromEmail.Text);
MailAddress toAddress = new MailAddress(txtToEmail.Text);
myMessage.From = fromAddress;
myMessage.To.Add(toAddress);
myMessage.Subject = "Email From Admin";
myMessage.IsBodyHtml = false;
myMessage.Body = txtMessage.Text + "\r\n" + "This message was sent from: " +
"." + "\r\n" + "\r\n" +
"This email was sent to " + txtToEmail.Text + ".";
//Doesn't have to be local... just enter your
//SMTP server's name or ip address!
System.Net.NetworkCredential netcer = new System.Net.NetworkCredential();
netcer.UserName = "uname smtp"; netcer.Password = "pass smtp";
myMail.Credentials = netcer;
myMail.Host = "smtp server";
myMail.Send(myMessage);
lblMessageSent.Text = "Your message has been sent to " + txtToEmail.Text + ".";
لطفا اگه کسی در این زمینه کار کرده پاسخ بزاره.ممنون
من کد زیر را برای ارسال ایمیل در دات نت 2 نوشتم و از کلاس net هم استفاده کردم اما با مشکل زیر برخورد می کنم .
No connection could be made because the target machine actively refused it
کد من به این شکل نوشته شده
MailMessage myMessage = new MailMessage();
SmtpClient myMail = new SmtpClient();
if (Page.IsValid)
{
MailAddress fromAddress = new MailAddress(txtFromEmail.Text);
MailAddress toAddress = new MailAddress(txtToEmail.Text);
myMessage.From = fromAddress;
myMessage.To.Add(toAddress);
myMessage.Subject = "Email From Admin";
myMessage.IsBodyHtml = false;
myMessage.Body = txtMessage.Text + "\r\n" + "This message was sent from: " +
"." + "\r\n" + "\r\n" +
"This email was sent to " + txtToEmail.Text + ".";
//Doesn't have to be local... just enter your
//SMTP server's name or ip address!
System.Net.NetworkCredential netcer = new System.Net.NetworkCredential();
netcer.UserName = "uname smtp"; netcer.Password = "pass smtp";
myMail.Credentials = netcer;
myMail.Host = "smtp server";
myMail.Send(myMessage);
lblMessageSent.Text = "Your message has been sent to " + txtToEmail.Text + ".";
لطفا اگه کسی در این زمینه کار کرده پاسخ بزاره.ممنون