Hi in my website, i am using email feature for registration where password is going to be send by email.

I am using following code

using System.Net.Mail;
MailMessage objMsg = new MailMessage();
        objMsg.IsBodyHtml = false;
        objMsg.From = new MailAddress(ConfigurationManager.AppSettings["AdminMailID"].ToString());
        objMsg.To.Add(new MailAddress(txtEmail.Text.Trim()));
        objMsg.Subject = "Your registration information.";
        string emailFormat = Resources.MasterResource.emailformat.ToString();
        emailFormat = emailFormat.Replace("USERNAME", txtName.Text);
        emailFormat = emailFormat.Replace("pUNAME", txtLoginID.Text.Trim().ToLower());
        emailFormat = emailFormat.Replace("pPASSWORD", password);
        emailFormat = emailFormat.Replace("pConsumerNumber", txtConsumerNumber.Text.Trim().ToLower());
        emailFormat = emailFormat.Replace("pConsumerName", txtName.Text.Trim());
        objMsg.Body = emailFormat;

        SmtpClient objSmtpClient = new SmtpClient(ConfigurationManager.AppSettings["SmtpServer"].ToString(), 25);
        objSmtpClient.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["SmtpServerAuthenticatePassword"].ToString(), ConfigurationManager.AppSettings["SmtpServerAuthenticateUser"].ToString());
        catch (Exception ex)
            throw new Exception(GetLocalResourceObject("SMTPError").ToString());
        { }

According to above code, following are the key points 1. Email format is text not HTML 2. The body of mail is placed inside globalresourse file

Problem area 1. There are paragraph implemented in mail body How it happens in text format. 2. My mail body have break line
how can i implement in text format

Please help?

[Edit] How can we write hyperlink inside text mail.

Important point is that i have written mail body inside master resource file? I not getting how can we write character for above mentioned points


For break line, use \n or \r\n, I guess. For paragraph, just use break line to separate them all.

text file is text like in notepad.

+1  A: 

Don't invent your own technique to do this- use the MailDefinition class. One example can be found here.

Thanks for that, I hadn't heard of that and was just about preparing to write my own for a new project. You never stop learning...
I have not implemented my own. I am using System.Net.Mail; for email. The point where i struct is that where i am not able replacement of <br><a href> and <p>.Also i store my message text inside global resource file.I would like to know how should i insert above characters inside global resource file for mail text format. Any example
Hemant Kothiyal
@Hemant. You have created your own templating functionality- MailDefinition provides templating functionality for you.