PDA

View Full Version : مشکل این کد چی ...



kezack
جمعه 17 خرداد 1387, 16:43 عصر
با سلام من کد زير را در صفحه اي داخل سايتي نوشتم و آپلود کردم ولي با يک خطا مواجه شدم لطفا کمکم کنيد.
اينم کد برنامه ام
************************************************** **********
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
public partial class Mail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{

MailMessage objmail = new MailMessage();
objmail.From = System.Configuration.ConfigurationSettings.AppSett ings["Email"];
objmail.To = TextBox1.Text;
objmail.Subject = "salam";
objmail.BodyFormat = MailFormat.Html;
objmail.BodyEncoding = System.Text.Encoding.UTF8;
objmail.Body = "thank for register";
objmail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
objmail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = 25;
objmail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
objmail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = System.Configuration.ConfigurationSettings.AppSett ings["SMTPusername"];
objmail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = System.Configuration.ConfigurationSettings.AppSett ings["SMTPpassword"];
SmtpMail.SmtpServer = System.Configuration.ConfigurationSettings.AppSett ings["SMTP"];
SmtpMail.Send(objmail);
TextBox1.Text = "";

}

}
************************************************** ***
اينم قسمت WebConfig
******************
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="SMTP" value="Localhost"/>
<add key="SMTPusername" value=""/>
<add key="SMTPpassword" value=""/>
<add key="Email" value="Morteza_2753@yahoo.com"/>
<add key="Path" value="http://Data-Galaxy.com"/>
</appSettings>
<connectionStrings>
</connectionStrings>
<system.web>
<customErrors mode="Off"/>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<authorization>
<allow roles="Kezack" />
</authorization>
<compilation debug="true"/>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>
************************
اينم خطا ي برنامه ام
Server Error in '/' Application.
--------------------------------------------------------------------------------
The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available

Source Error:

Line 50: objmail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = System.Configuration.ConfigurationSettings.AppSett ings["SMTPpassword"];
Line 51: SmtpMail.SmtpServer = System.Configuration.ConfigurationSettings.AppSett ings["SMTP"];
Line 52: SmtpMail.Send(objmail);
Line 53: TextBox1.Text = "";
Line 54:

لطفا کمکم کنيد

kezack
جمعه 17 خرداد 1387, 20:15 عصر
بابا یکی نیست کمکم کنه

KavoshGar_ir
شنبه 18 خرداد 1387, 16:39 عصر
فکر می کنم مشکل از SmtpClient باشه - اینطور بنویس :


SmtpClient smtp = new SmtpClient("میل سرور");
smtp.Credentials = new NetworkCredential("ID", "PASS");
// smtp.Host = "localhost";
smtp.Send(objmail);