Solved

Stringbuilder

Posted on 2012-03-15
4
234 Views
Last Modified: 2012-03-16
Hello,

I am using string builder to create a table that will go into an email.

Basically this works fine but what I want to do is have a table, the the first row spans across several columns.
then the second row would have several columns.

Is there anyway to have a table row span multiple columns using SB?

Thank You.
0
Comment
Question by:Wildone63
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 37725926
Not sure how you are doing this, but if you want a table row to span several column then all you do is add the colspan attribute to the td, i.e

<table>
<tr>
<td colspan="2">Spans two columns</td>
</tr>
<tr>
<td>First Column</td>
<td>Second Column</td>
</tr>
</table>
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37726111
Another approach is to generate an HtmlTable structure, and then render the control to a StringWriter and an HtmlTextWriter.
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37726570
private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("your_email_address@gmail.com");
                mail.To.Add("to_address");
                mail.Subject = "Test Mail - 1";

                mail.IsBodyHtml = true;
                string htmlBody;

                htmlBody = "<table><tr><td colspan="2">2 col</td></tr><tr><td>First Column</td><td>Second Column</td></tr></table>";

                mail.Body = htmlBody;

                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);
                MessageBox.Show("mail Send");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }

Open in new window


Ref:http://csharp.net-informations.com/communications/csharp-html-email.htm
Have a look at this one as well:-
http://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=6;

you can always replace the htmlbody string with stringbuilder.
0
 
LVL 1

Author Closing Comment

by:Wildone63
ID: 37729257
Exactly what I was looking for.

Thank You!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question