Solved

Stringbuilder

Posted on 2012-03-15
4
230 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now