Home > DeveloperSection > Forums > About Sending an Email after registration
Andrew Watson
Andrew Watson

Total Post:39

Points:273
Posted on    February-17-2011 4:46 AM

 ASP.Net ASP.Net 
Ratings:


 2 Reply(s)
 1503  View(s)
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


Uttam Misra

Total Post:125

Points:897
Posted on    February-17-2011 5:03 AM

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



Uttam Misra

Total Post:125

Points:897
Posted on    February-17-2011 5:04 AM


Modified On Feb-17-2011 05:04:33 AM

Don't want to miss updates? Please click the below button!

Follow MindStick