Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
bilnaadRank #2,169 · 655 reputationPosted Nov 7, 2004, 8:04 AM EST
fadil197777 reputationPosted Nov 7, 2004, 9:06 PM EST
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.Mail ; namespace C_sharp { ///
/// Summary description for Email.
///
public class Email : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.DropDownList listSubject;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
if ((this.TextBox1.Text=="")|| (this.listSubject.SelectedItem.Text=="Nothing"))
{
this.Label1.Visible= false;
this.Label2.Visible=true;
//return;
}
else
if ((this.TextBox1.Text.Trim()=="" )|| (this.listSubject.SelectedItem.Text=="Nothing"))
{
this.Label1.Visible= false;
this.Label2.Visible=true;
//return;
}
else
{
// Put user code to initialize the page here
MailMessage msgMail = new MailMessage();
msgMail.To = "[email protected],[email protected]";//can have more than one person
//msgMail.Cc = "[email protected]";
msgMail.From = "[email protected]";
//msgMail.Subject = "Hi fadil!, done!!";
msgMail.Subject = this.listSubject.SelectedItem.Text;// instead of text
msgMail.BodyFormat = MailFormat.Html;
//string strBody = "Hello World" +
// " ASP.NET";
string strBody = this.TextBox1.Text;
msgMail.Body = strBody;
msgMail.Attachments.Add(new MailAttachment("C:\\aaa.doc"));
SmtpMail.Send(msgMail);
this.Label1.Visible=true;
this.Label2.Visible = false;
this.TextBox1.Text=null;
}
}
}
}
shehan_19834 reputationPosted Nov 11, 2004, 9:20 PM EST
SchelianHP2 reputationPosted Nov 12, 2004, 1:16 AM EST