Hey,
I need to send info from a contact page to both administrator and also the client (if send copy checkbox is checked). It is an aspx page, and my code keeps bombing. Could someone look for a problem in my code? (also, maybe the problem lies with the server?)
protected void ButtonSubmit_Click(object sender, EventArgs e)
{
if (Page.IsValid)//if captcha is entered correctly, this will be true
{
bool error = false;
if (TextBoxSurname.Text == "")
{
LabelSurnameError.Visible = true;
error = true;
}
else
{
LabelSurnameError.Visible = false;
}
if (TextBoxEmail.Text == "")
{
LabelEmailError.Visible = true;
error = true;
}
else
{
LabelEmailError.Visible = false;
}
if (TextBoxEmail.Text != TextBoxConfirmEmail.Text)
{
LabelConfirmEmailError.Visible = true;
error = true;
}
else
{
LabelConfirmEmailError.Visible = false;
}
if (TextBoxEnquiry.Text == "")
{
LabelEnquiryError.Visible = true;
error = true;
}
else
{
LabelEnquiryError.Visible = false;
}
if (error == true)
return;
MailMessage msg = new MailMessage(TextBoxEmail.Text, "juan.venter@hotmail.com");
msg.Subject = "Backpackers portal Enquiry";
if (CheckBoxCopy.Checked)
{
msg.Bcc.Add(TextBoxEmail.Text);
}
msg.Body = "Submitted By: " + DropDownListTitle.Text + " " + TextBoxSurname.Text + "\n";
if (TextBoxFirstname.Text != "")
{
msg.Body += "Firstname : " + TextBoxFirstname.Text + "\n";
}
if (TextBoxContactNum.Text != "")
{
msg.Body += "Contact Number : " + TextBoxContactNum.Text + "\n";
}
if (TextBoxCell.Text != "")
{
msg.Body += "Cell Number : " + TextBoxCell.Text + "\n";
}
msg.Body += "Enquiry : " + TextBoxEnquiry.Text;
SmtpClient sm = new SmtpClient();
sm.Host = "196.22.134.22";
sm.Send(msg);
//Response.Write("<script>");
//Response.Write("Set myMail=CreateObject('CDO.Message')");
//Response.Write("myMail.Subject='Sending email with CDO'");
//Response.Write("myMail.From='juan.venter@hotmail.com'");
//Response.Write("myMail.To='juan@semper.co.za'");
//Response.Write("myMail.TextBody='This is a message.'");
//Response.Write("myMail.Send");
//Response.Write("set myMail=nothing");
//Response.Write("</script>");
}
}
Thanks!!!!
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.