بسم الله الرحمن الرحيم
السلام عليكم ورحمة الله وبركاته،
انا اشتغل على windows xp home edition و visual studio 2003 .net
عندي برنامج بسيط يحاول ارسال ايميل
انشأت ايميل جديد مع google لاستخدام الـsmtp
وعندي هذا الكود:
void sendEmail()
{
try
{
try
{
MailMessage message = new MailMessage();
//Because using google server, requires SSL
message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1 );
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername","SmtpHostUserName" );
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword","SmtpHostPassword" );
message.From = "mygmail@gmail.com";
message.To = "myyahoo@yahoo.com";
message.Subject = "Test Subject";
message.Body = "Test Body";
try
{
SmtpMail.SmtpServer = "smtp.google.com";
SmtpMail.Send(message);
}
catch(System.Web.HttpException ehttp)
{
MessageBox.Show("Catch1");
MessageBox.Show(ehttp.ToString());
}
}
catch(IndexOutOfRangeException)
{
MessageBox.Show("IndexOutOfRangeException");
}
}
catch(System.Exception e)
{
MessageBox.Show("Catch2");
MessageBox.Show(e.ToString());
}
}//end sendEmail function
عند التنفيذ، يطلع لي هذه الـexception عند الـcatch الاول
System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->System.Runtime.InteropServices.COMException(0x80040213):The transport failed to connect to the server.
ارجوا المساعده لحل هذه المشكله
شكرا و -waf