dhanjish Posted February 17, 2007 Share Posted February 17, 2007 hello,I want to send some data in mail with Line breaksam getting the data from the database into a variable, where new line entries are stored as spaces.while retrieving from database i am using Regex object to replace '\n' with "<br>"I am able to get this result into asp Datgrid.But while sending in same way to mail, its showing data as single para.Please let me know if theres any solution to my problem.Looking forward for a quick response,Romita Link to comment Share on other sites More sharing options...
jesh Posted February 19, 2007 Share Posted February 19, 2007 If you are sending the email in HTML format, then the <br />s should work just fine. If, on the other hand, you are sending the email in plain-text format, you'll need to keep the "\n"s.plain-text: string emailBody = "This is a sample.\n\nThis line has two line breaks above it.\nDone."; HTML string emailBody = "This is a sample.<br /><br />This line has two line breaks above it.<br />Done."; If you are using the System.Net.Mail.MailMessage class to send the email, you can tell it whether to send as plain-text or HTML by using the .IsBodyHtml property: MailMessage message = new MailMessage(fromAddress, toAddress);message.Subject = "Subject";message.Body = emailBody;message.IsHtmlBody = true; // or false, depending... Link to comment Share on other sites More sharing options...
dhanjish Posted February 20, 2007 Author Share Posted February 20, 2007 Hi, We tried ur code and it worked ..........Thank u for ur response Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now