Click here to Skip to main content
16,012,082 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all

I am working with information sender i need code in c#

C#
string Body = "User Name :" + Txt_Name.Text+", "  + "Contact No :" ;


For giving , we are using ","

What i need to give for New line, and other things please help me
Posted
Updated 4-Jan-12 0:45am
v3

C#
string Body = "User Name :" + Txt_Name.Text+"\\n"  + "Contact No :" ;

\n is for new line in C#. As \ is Escape sequence we use \\.

Karthi
 
Share this answer
 
v2
Try this,


C#
string Body = "User Name :" + Txt_Name.Text+" <br /> "  + "Contact No :" ;



Thanks..
 
Share this answer
 
Environment.NewLine


Use This

Check this example
txtEmailBodyDB.Text = "Hi There " + Environment.NewLine + " " + Environment.NewLine + "These are  auto genrated Mails.Kindly Ignore these mails. " + 
 
Share this answer
 
v2
Comments
manoharnch 4-Jan-12 6:46am    
I tried it but not working
manoharnch 4-Jan-12 6:46am    
string Body = "User Name :" + Txt_Name.Text+", " + "Contact No :" + Txt_Contact.Text + ", " + "Email :" + Txt_Email.Text + ", " + "Address :" +"'"+ Txt_Address.Text+"'";
Anuj Banka 4-Jan-12 6:48am    
Check the Example Or you can create Html string and you can send mail content as HTML
manoharnch 4-Jan-12 6:51am    
string Body = "User Name :" + Txt_Name.Text + Environment.NewLine + ", " + Environment.NewLine + "Contact No :" + Txt_Contact.Text + Environment.NewLine + ", " + Environment.NewLine + "Email :" + Txt_Email.Text + ", " + "Address :" + "'" + Txt_Address.Text + "'";

But i am not getting mail in this format

Raj
asf
asdf
asdf


it is in asdf, asdf, asdf, asdf
Shobana16 4-Jan-12 6:57am    
try the solution 4 or 1
you can use html tag inside string
C#
string body = "You have received a status update from " + Session["name"].ToString() + ", Department : " + Session["deptt"].ToString() + "  ,with reference to Assignment ID: " + lblassno.Text + " /Task ID: " + taskid + ". Kindly login TMS on Intranet Portal to view the details.";
       body += "<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style="mso-bidi-font-style:normal;font-style: italic;font-size: small;">This is a System generated message,";
       body += "kindly do not reply to this.<o:p xmlns:o="#unknown"></o:p></span>";

but ensure when you send mail
C#
MailMessage m = new MailMessage("Omaxe Ltd.<testr@gmail.com>", To);
               m.Subject = Subject;
               m.Body = Body;
               m.IsBodyHtml = true;
 
Share this answer
 
Comments
manoharnch 4-Jan-12 6:45am    
I need it in c#
uspatel 4-Jan-12 6:58am    
are u sending it by mail?
uspatel 4-Jan-12 7:00am    
if yes, it works.....
but ensure m.IsBodyHtml = true;
you have to use break tag
<br/>

that is like
C#
string Body = "User Name :" + Txt_Name.Text+ "<br/> "  + "Contact No :" ;
 
Share this answer
 
v3
Comments
manoharnch 4-Jan-12 6:45am    
i need it in c#

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900