473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to format the body of outgoing emails in C#?

2
mailMessage.Body = "text1 : " + txtBody.Text;
mailMessage.Body += "text2 : " + TextBox1.Text;

out put:
>text1 xyz text2 xyz

I want to seperete these two lines in mail which i got
as
>text1 : xyz
>text2 : xyz

please reply me how to do it......
May 16 '10 #1
5 6225
tlhintoq
3,525 Expert 2GB
May I suggest picking up a basic C# introductory book? It's not that people here don't want to be helpful, but there is a certain amount of basic learning work that one should really take upon themselves before asking for help. There are so many great "How do I build my first application" tutorials on the web... There are dozens of "Learn C# in 21 days", "My first C# program" books at your look book seller or even public library... Asking a forum, any forum, to hand-hold you through it is just redundant. In many ways it disrespects the people who have invested dozens of hours in the on-line tutorials and those that spent thousands of hours in authoring books.

Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5
is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.

C# Cookbooks
Are a great place to get good code, broken down by need, written by coding professionals. You can use the code as-is, but take the time to actually study it. These professionals write in a certain style for a reason developed by years of experience and heartache.

Microsoft Visual Studio Tip, 251 ways to improve your productivity, Microsoft press, ISBN 0-7356-2640-5
Has many, many great, real-world tips that I use all the time.

The tutorials below walk through making an application including inheritance, custom events and custom controls.
Building an application Part 1
Building an application part 2
May 16 '10 #2
tlhintoq
3,525 Expert 2GB
You need to learn how to do basic string editing.
You can insert special control characters such as
\t for tab
\n for newline
and so on. This would all be covered in any of the "My first program" tutorials online or in a "Learning C# for the beginner" book.
May 16 '10 #3
ashir
2
@tlhintoq
Thanks a lot giving me reply but i am talking about specifically body part in mail i had used

1.
mailMessage.Body = "text1 : " + txtBody.Text + "\n";
mailMessage.Body += "text2 : " + TextBox1.Text;

2.
mailMessage.Body = "text1 : " + txtBody.Text + "\r\n";
mailMessage.Body += "text2 : " + TextBox1.Text;

3.
mailMessage.Body = "text1 : " + txtBody.Text + "Environment.NewLine";
mailMessage.Body += "text2 : " + TextBox1.Text;

all these three but nothing is working at mail part means when the person got mail in his mail's body part output is coming as i show for all above three as following :
output :
>text1 xyz text2 xyz

so i ask how can i divide lines in different rows as

>text1 xyz
>text2 xyz
please now reply me if you can ...
Thanks a lot for reply my question.
Thanks With Regards,
Ashir
May 17 '10 #4
PRR
750 Expert 512MB
Use System.Environment.NewLine in your message text

Set the MailMessage.IsBodyHtml
and use html elements in a string and add it to the body of mail message.
May 17 '10 #5
tlhintoq
3,525 Expert 2GB
You are just thrashing about wildly. Trying to guess a way to do this, rather than read and learn and comprehend.

Expand|Select|Wrap|Line Numbers
  1. mailMessage.Body = "text1 : " + txtBody.Text + "Environment.NewLine";
If your wrap quotions around "Environment.NewLine" it is not a variable. It is just text that says Environment.NewLine.

Expand|Select|Wrap|Line Numbers
  1. mailMessage.Body += "\n\nText2: THis is my second line of text";
May 17 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: vishal | last post by:
i am getting following error. Warning: mail() : Failed to connect to mailserver at "smtp.gmail.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in...
0
by: MailSweeper | last post by:
Your message did not reach some or all of the intended recipients. From: python-list@python.org Subject: Returned mail: Data format error Sent: Fri, 12 Nov 2004 23:37:18 +0700 The...
1
by: Hari | last post by:
Hi all! I am trying to send mail using outlook in my web application. i am using Outlook Express. Actually i am saving it in DRAFTS folder instead of sending it. My system are in network. I hard...
2
by: Paul Turley | last post by:
Does anyone have some sample code for sending an HTML formatted message using CDONTS? Thanks RE: Sending HTML formatted mail using CDONTS -- Paul Turley, MCSD, MCAD, MCT, MSF...
1
by: mg | last post by:
I've been sending e-mail messages without difficulty using message.Body = msgText until I increased to a size that causes the received message to be truncated. Is there a limit to the size of...
1
by: SMG | last post by:
Hi All, My Send mail system was working very fine, today suddenly it started giving me following error. Can any one suggest why this is happening so. I am using system.Web.Mail "The requested...
2
by: Abhi | last post by:
i need to create a user in web mail using dotnet coad by using webmailserver api ex: xxx is my webmail then i want to create to a user in that webmail xxx ex: yyy@xxx.com how i should do in...
0
by: jamil abou khalil | last post by:
Hi all, I need to know how to authenticate a user before sending a mail using a C# application. The source code i use is this: private void sendMailButton_Click(object sender, EventArgs e)...
0
by: MAILER-DAEMON | last post by:
This is a multi-part message in MIME format. --FLMNOQRSTUVXYZabcefghjklmnoqrstuvxyz0124 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This message has been...
2
by: Muleskinner | last post by:
Hi forum, I use the following code to open the users default mail client with values set in reciever, subject and body fields: Dim msg As String = String.Format("mailto:{0}{1}",...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.