المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Error while sending mail using System.Net.Mail in C#



C# Programming
01-19-2010, 08:30 AM
Private Void SendMail()
{
MailMessage mMsg = new MailMessage();
SmtpClient sClient = new SmtpClient();
string sHtmlBody = "Test mail ";
AlternateView avHtml = AlternateView.CreateAlternateViewFromString(sHtmlBody);
NetworkCredential crMail = new NetworkCredential();
mMsg.AlternateViews.Add(avHtml);
mMsg.From = new MailAddress("rishi@wi.com","Rishi");
mMsg.To.Add("test@wi.com","Test");
mMsg.Subject = "Test Mail");

//This is my actual local mail server ip, port and username password
//which I've already configured in my outlook and it is working fine.

//-------------------------------
sClient.Host = "192.168.1.7";
sClient.Port = 26;
crMail.UserName = "rishi@wi.com";
crMail.Password = "12345";
//-------------------------------

sClient.UseDefaultCredentials = False;
sClient.Credentials = crMail;
sClient.Send(mMsg);
}

When call this function this shows the error:

"Mail box unavailable. The server response was: No Such User"

There is no issue with this smtp details the same already I've configured in my MS outlook. And also it working fine in VB6 program using CDO.

My requirement is I want to send mails through SMTP which may available in locally or globally.

If anybody have an idea with this pls reply here..

Thanks & Regards,
Rishi

WinCrs