بسم الله الرحمن الرحيم
لقد استخدمت الكود التالي في ارسال فورمه علي الايمل
protected void Button1_Click(object sender, EventArgs e)
{
{
// System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0
// System.Net.Mail.SmtpClient is the alternate class for this in 2.0
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);
// You can specify the host name or ipaddress of your server
// Default in IIS will be localhost
//لقد وضعت هنا اسم الهوست الخاص بي
smtpClient.Host = "mail.myhost.com";
//Default port will be 25
smtpClient.Port = 25;
//From address will be given as a MailAddress Object
message.From = fromAddress;
// To address collection of MailAddress
message.To.Add("support@myhost.com");
message.Subject = "اقتراح ";
// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("admin1@yoursite.com")
message.CC.Add("support@myhost.com");
// You can specify Address directly as string
message.Bcc.Add(new MailAddress("support@myhost.com"));
message.Priority = MailPriority.High;
//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = true;
string strBody;
// Message body content
//message.Body = txtMessage.Text;
strBody = "<html><body bgcolor=#CFD7EA>";
strBody += "<table align=center>";
strBody += " <tr>";
strBody += "<td align=center>";
strBody += "<div align=center><h1> اقتراح </h1><div></td>";
strBody += " </tr>";
strBody += " </table>";
strBody += "<table align=right>";
strBody += " <tr>";
strBody += "<td align=right>" + txtProName.Text;
strBody += " </td>";
strBody += "<td align=right>";
strBody += "<font color= #000066><u><strong>:اسم الاقتراح</strong></u></span></td>";
strBody += " </tr>";
strBody += " <tr>";
strBody += "<td align=right>" + txtDis.Text;
strBody += " </td>";
strBody += " <td align=right>";
strBody += "<font color= #000066><u><strong>:وصف البرنامج </strong></u></span></td>";
strBody += " </td>";
strBody += " </tr>";
strBody += " <tr>";
strBody += "<td align=right>" + txtProAim.Text;
strBody += " </td>";
strBody += " <td align=right>";
strBody += "<font color= #000066><u><strong>:اهداف البرنامج</strong></u></span></td>";
strBody += " </td>";
strBody += " </tr>";
strBody += " <tr>";
strBody += "<td align=right>" + txtNote.Text;
strBody += " </td>";
strBody += " <td align=right>";
strBody += "<font color= #000066><u><strong>:ملاحظات </strong></u></span></td>";
strBody += " </td>";
strBody += " </tr>";
strBody += " <tr>";
strBody += "<td align=right>" + txtEmail.Text;
strBody += " </td>";
strBody += " <td align=right>";
strBody += "<font color= #000066><u><strong>: البريد الالكتروني</strong></u></span></td>";
strBody += " </td>";
strBody += " </tr>";
strBody += " <tr>";
strBody += "<td align=right>" + txtName.Text;
strBody += " </td>";
strBody += " <td align=right>";
strBody += "<font color= #000066><u><strong>: اسم الراسل</strong></u></span></td>";
strBody += " </td>";
strBody += " </tr>";
strBody += " <tr>";
strBody += "<td align=right>" + lstCountry.SelectedItem.ToString();
strBody += " </td>";
strBody += " <td align=right>";
strBody += "<font color= #000066><u><strong>:الدوله</strong></u></span></td>";
strBody += " </td>";
strBody += " </tr>";
strBody += " <tr>";
strBody += "<td align=right>" + txtCity.Text;
strBody += " </td>";
strBody += " <td align=right>";
strBody += "<font color= #000066><u><strong>: المدينه </strong></u></span></td>";
strBody += " </td>";
strBody += " </tr>";
strBody += " <tr>";
strBody += "<td align=right>" + txtPhone.Text;
strBody += " </td>";
strBody += " <td align=right>";
strBody += "<font color= #000066><u><strong>:الهـاتـــف</strong></u></span></td>";
strBody += " </td>";
strBody += " </tr>";
strBody += "</table>";
strBody += "</body>";
strBody += "</html>";
message.Body = (strBody);
// Send SMTP mail
smtpClient.Send(message);
QueryResult.Text = "شكرا .";
txtProName.Text = "";
txtDis.Text = "";
txtProAim.Text="";
txtNote.Text="";
txtEmail.Text = "";
txtName.Text = "";
lstCountry.Text="";
txtCity.Text = "";
txtPhone.Text = "";
}
catch (Exception ex)
{
QueryResult.Text = "Send Email Failed.<br>" + ex.Message;
}
}
}ولقد جربت الكود وارسل ايميل علي الايمل الخاص بالهوست وايضا علي اميلي الشخصي علي هوت ميل
عند رفعه الصفحه علي السيرفر لا يعمل الكود تماما
وتظهر لرساله
Send Email Failed.
Failure sending mail.
اتمني ان يساعدني احدكم
شكراااا

