الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

عمل صفحة contact us

بدأه searcher11 في 1 يونيو 2011 · 2 رد · 479 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

طلب مني عمل صفحة مثل صفحة contact us

بحثت عنه وقرات وطبقت الكود

لكن لما اضغط على button يظهر لي خطا

وهذا الكود الي طبقته

using System;   
using System.Collections.Generic;   
using System.Web;   
using System.Web.UI;   
using System.Web.UI.WebControls;   
using System.Net.Mail;


public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(Email.Text);

            mail.To.Add("myemail@gmail.com");
            mail.Subject = subject.Text;
            mail.IsBodyHtml = true;
            mail.Body = "First Name: " + fname.Text + "<br/>" + "subject is" + subject.Text + "<br/> Email is " + Email.Text + "<br/>";
            mail.Body += message.Text;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.EnableSsl = true;
            smtp.Send(mail);



    }
}

اتمنى ان أجد الحل وشكرا لكم

post-224679-006117100 1306942520_thumb.g

المرفقات
Capture.GIF

تم تعديل هذه المشاركة بواسطة searcher11 في 1 يونيو 2011 في 18:37

#2

ممكن تجرب هذا الكود فهوه يعمل بطريقة رائعه

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
using System.Net.Mail;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        try
        {
            MailMessage msg = new MailMessage();
            msg.To.Add("بريدي الإلكتروني في الجي ميل");
            MailAddress address = new MailAddress(txtEmail.Text.Trim());
            msg.From = address;
            msg.IsBodyHtml=true;
            msg.Subject ="الموضوع" + " :" + txtSubject.Text;
            msg.Body = txtEmail.Text + "<br/><br/>" + txtMessage.Text;

            SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
            client.EnableSsl = true;
            client.UseDefaultCredentials = false;

            NetworkCredential card = new NetworkCredential("البريد الإلكتروني", "كلمة السر");
            client.Credentials = card;
            client.Send(msg);
            lblResult.Text = "تم ارسال رسالتك بنجاح";

            txtEmail.Text = "";
            txtSubject.Text = "";
            txtMessage.Text = "";

        }
        catch {
            lblResult.Text = "فشل ارسال الرساله حاول مرة اخرى";
              }
    }
	}

تم تعديل هذه المشاركة بواسطة Xacker في 2 يونيو 2011 في 16:07

#3

شكرا لك اخي

تم حل المشكلة

مواضيع مشابهة