PDA

View Full Version : Auto email reply


QBall777
08-07-2008, 01:18 PM
Hi

I have a registration form that a user enters their details and then their details gets delivered to the website administrator, this all works fine. I now need the user to receive an automatic email reply in the form of a html template. Does anyone have any ideas??

This is my Code for the email to be sent to the administrator

}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
string body = "Registration for some Registration website\n\n";
body += "Name: " + txtName.Text + "\n";
body += "Company Name: " + txtCompany.Text + "\n";
body += "Email: " + txtEmail.Text + "\n";


// send the mail
MailMessage msg = new MailMessage();
msg.IsBodyHtml = false;
msg.From = new MailAddress(txtEmail.Text, txtName.Text);
msg.To.Add(new MailAddress("administrator@website.co.uk"));
//if (!string.IsNullOrEmpty(Globals.Settings.ContactForm.MailCC))
// msg.CC.Add(new MailAddress(Globals.Settings.ContactForm.MailCC));
msg.Subject = "some Registration";
msg.Body = body;
new SmtpClient().Send(msg);
// show a confirmation message, and reset the fields
lblFeedbackOK.Visible = true;
lblFeedbackKO.Visible = false;
btnSubmit.Enabled = false;
}
catch (Exception)
{
lblFeedbackOK.Visible = false;
lblFeedbackKO.Visible = true;
}
}

My email template is called RegistrationMail.html

Thanks

Nischumacher
08-12-2008, 12:49 PM
write the code to send a mail to user, just after you send mail to the admininistrator...
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
string body = "Registration for some Registration website\n\n";
body += "Name: " + txtName.Text + "\n";
body += "Company Name: " + txtCompany.Text + "\n";
body += "Email: " + txtEmail.Text + "\n";

// send the mail
MailMessage msg = new MailMessage();
msg.IsBodyHtml = false;
msg.From = new MailAddress(txtEmail.Text, txtName.Text);
msg.To.Add(new MailAddress("administrator@website.co.uk"));
msg.Subject = "some Registration";
msg.Body = body;
new SmtpClient().Send(msg);

// send the auto-reply mail
body = "body for the auto-reply mail";
MailMessage msg = new MailMessage();
msg.IsBodyHtml = false;
msg.From = new MailAddress("administrator@website.co.uk"));
msg.To.Add(new MailAddress(txtEmail.Text));
msg.Subject = "Thank you for registering";
msg.Body = body;
new SmtpClient().Send(msg);

// show a confirmation message, and reset the fields
lblFeedbackOK.Visible = true;
lblFeedbackKO.Visible = false;
btnSubmit.Enabled = false;
}
catch (Exception)
{
lblFeedbackOK.Visible = false;
lblFeedbackKO.Visible = true;
}
}

QBall777
08-18-2008, 03:08 PM
Thanks for your help