About Sending an Email after registration

Total Post:39

Points:273
 2015  View(s)
Ratings:
Rate this:
Hi,
I want a code to send an email, to a user after registration. That email will contain some images and a link back url for an account confirmation.
Please provide me sample of code.

Thanks,
Andrew
  1. Post:127

    Points:915
    Re: About Sending an Email after registration

    check this code...I hope this will help you..


    using System.Web.Mail;
    try
                {
                    string smtpServer = "relay-hosting.secureserver.net";
                    string userName = "contact@yourdomain.com";
                    int cdoBasic = 1;
                    int cdoSendUsingPort = 2;
                    MailMessage msg = new MailMessage();
                    if (userName.Length > 0)
                    {
                        msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer);
                        msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
                        msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort);
                        msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic);
                        //msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName);
                        // msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
                    }
                    msg.To = "contact@yourdomain.com";
                    msg.From = "contact@yourdomain.com";
                    msg.BodyFormat = MailFormat.Html;
                    msg.Subject = txtSubject.Text;          
                    msg.Body = "Name: " + txtName.Text + "<br /><br />Company: " + txtCompany.Text + "<br /><br />Email: " + txtEmail.Text + "<br />" + txtDetails.Text;
                    SmtpMail.SmtpServer = smtpServer;
                    SmtpMail.Send(msg);
     
                    msg.To = txtEmail.Text.Trim();
                    msg.From = "donotreply@yourdomain.com";
                    msg.BodyFormat = MailFormat.Html;
                    msg.Subject = txtSubject.Text;
                    msg.Body = @"Hi,<br/>
                    Thanks for contacting , we will review your information and try to get back to you ASAP.<br/>
                    Thanks;
     
                    SmtpMail.SmtpServer = smtpServer;
                    SmtpMail.Send(msg);
                    ValidationSummary1.Visible = false;
                    lblStatus.Visible = true;
                    lblStatus.Text = "Message Sent Sucessfully.";
     
                }
                catch
                {

     

    cheers


      Modified On Mar-29-2018 03:49:49 AM
  1.   Modified On Feb-17-2011 05:04:33 AM

Answer